У меня есть класс FormTypeОбязательное поле в Symfony2
<?php
class FormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('price', 'integer', [
'required' => true,
'label' => 'Tranche/QF minimal(e)',
])
->add('reductionPourcentage', 'integer', [
'required' => true,
'label' => 'Reduction in Pourcentage'
])
->add('reductionEuros', 'money', [
'required' => true,
'label' => 'Reduction in Euro'
])
;
}
Я хочу обязательно поля reductionPourcentage и reductionEuros. Но пользователю просто нужно заполнить один из них. Не они оба.
Как я могу сделать это простым способом с помощью FormBuilderInterface?
Должен ли я использовать Constraint: http://symfony.com/doc/current/cookbook/validation/custom_constraint.html
Я не уверен, чтобы понять ваше желание ... Может быть, поле выбора ... – scoolnico
Кто-то найдет ответ о полях realtive. [здесь] (http://stackoverflow.com/questions/20786365/symfony2-how-to-validate-an-input-field-is-not-blank-only-when-checkbox-is-tru/20802838#20802838) –