I have 5 fields in one form which is as below:
class ItempriceFormType extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder->add('pergramprice', 'text', array('required' => false))
->add('eighthprice', 'text', array('required' => false))
->add('quarterprice', 'text', array('required' => false))
->add('halfprice', 'text', array('required' => false))
->add('ounceprice', 'text', array('required' => false))
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver) {
$resolver->setDefaults(array(
'data_class' => 'Acme\FrontBundle\Entity\Itemprice',
));
}
public function getName() {
return 'items_price';
}
}
I want to validate only one field means require only one field out of 5 fields. So how can I achieve this with symfony 2 validations.
Thanks in advance.