我有这个表单类型: public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('ageMin', NumberType::class), ->add('ageMax', NumberType::class,['mapped' => false]); }我的问题是,我想在提交表单之前验证此表达式:ageMin <= ageMax我已经尝试过此代码,但是不起作用 $resolver->setDefaults([ 'data_class' => User::class, 'constraints' => [new Assert\Expression([ 'expression' => 'value["ageMax] >= value["ageMin"]' ]),] ]);如果还有其他解决方案?
- 3 回答
- 0 关注
- 157 浏览
添加回答
举报
0/150
提交
取消