在 Symfony3 项目中,我有一个像这样的 SonataAdminBundle 表单:
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 字段中选择 24H 并自动将 rentalTimeType 更改为“Plage de jours”。
我已经阅读了很多关于使用 $subject 的主题,但这并不是我所需要的。
- change row color in sonata admin bundle dependent on a value of a field
- Correct way to use FormEvents to customise fields in SonataAdmin
- Sonata User Admin - Custom field dependency
那么有可能做我需要的吗?
最佳答案
您可以自定义特定于用户提交的数据的表单。
关于php - 根据 SonataAdminBundle 中的其他更改字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47225155/