I have defined a fieldset for phone numbers. This contains fields "type" (private, Office mobile ...) and "number". The Input filter for number is "required => true":
``
class PhoneFieldset extends BaseFieldset implements InputFilterProviderInterface
{
public function __construct()
{
parent::__construct('phones');
$this->setHydrator(new DoctrineHydrator($this->getEntityManager(), 'HtsBase\Entity\Phone'))
->setObject(new Phone());
$this->add(array(
'type' => 'DoctrineORMModule\Form\Element\EntitySelect',
'name' => 'type',
'options' => array(
'label' => 'Type',
'empty_option' => '',
'object_manager' => $this->getEntityManager(),
'target_class' => 'HtsBase\Entity\OptionlistPhoneType',
'property' => 'name',
),
'attributes' => array(
#'id' => 'type',
'class' => 'input-medium',
),
));
$this->add(array(
'name' => 'number',
'options' => array(
'label' => 'Number',
),
'attributes' => array(
'type' => 'text',
#'id' => 'number',
'class' => 'input-medium',
'maxlength' => '25',
'autocomplete' => 'off',
),
));
}
public function getInputFilterSpecification()
{
return array(
'type' => array(
'required' => false,
),
'number' => array(
'required' => true,
'filters' => array(
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'max' => 25,
),
),
),
),
);
}
``
Can i attach a validator/filter to the entire fieldset? So that if "type" AND "number" are empty the fieldset is valid, but validate if least one is filled out?