我有这个表单类型:
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"]'
]),
]
]);
如果还有其他解决方案?
万千封印
冉冉说