Php 根据SonataAdminBundle中的其他字段更改字段
在Symfony3项目中,我有一个SonataAdminBundle表单,如下所示:Php 根据SonataAdminBundle中的其他字段更改字段,php,symfony,sonata-admin,symfony3.x,Php,Symfony,Sonata Admin,Symfony3.x,在Symfony3项目中,我有一个SonataAdminBundle表单,如下所示: protected function configureFormFields(FormMapper $formMapper) { $formMapper->add('rentalTime', 'choice', array( 'label' => 'Durée de location', 'multiple' => fals
protected function configureFormFields(FormMapper $formMapper) {
$formMapper->add('rentalTime', 'choice', array(
'label' => 'Durée de location',
'multiple' => false,
'choices' => array(
'3H' => '3',
'24H' => '24',
)
));
$formMapper->add('rentalTimeType', 'choice', array(
'label' => 'Type de durée de location',
'multiple' => false,
'choices' => array(
'Heure(s)' => 'H',
'Plage de jours' => 'R'
)
));
.
.
.
当我更改rentalTime的值时,我想更改rentaltimeType的值。
示例:如果我在rentalTime字段中选择24小时,并自动更改“Plage de jours”的rentalTimeType
我已经读了很多使用$subject的主题,但这并不完全是我需要的
那么,是否可以执行我需要的操作?您可以针对用户提交的数据自定义表单
是的,我知道,但在客户端这不是实时的。只有当表单提交或重新打开以进行编辑时,才会出现这种情况。这里有一个ajax提交,因此第二个字段与第一个侧中的select选项相对。哦,好的,我没有看到。我要试试这个,我会让你知道的。谢谢