I'm not being able to validate a form Collection element, here is how my fieldset looks like:
class ProductFieldset extends Fieldset implements InputFilterProviderInterface
{
public function init()
{
$this->setName('product');
$this->add(array(
'name' => 'features',
'type' => 'Collection',
'options' => array(
'label' => 'Características do produto',
'count' => 0,
'should_create_template' => true,
'allow_add' => true,
'target_element' => array(
'type' => 'Text',
),
),
));
}
public function getInputFilterSpecification()
{
return array(
'features' => array(
'required' => false,
'filters' => array(
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'min' => 10,
),
),
),
),
);
}
}
If I add an element and leave it empty the validation passes, but it should not, since StringLength
requires at least 10 characters. I must be missing something, if someone can show me what I'm doing wrong I would be very thankful.