I have a form with an input type='text' name='article[]' . I don't know the number of article that can be post because there is a little javascript button where I can add as much I want input name=article[].
For now, I use Zend\InputFilter\InputFilter but the validators never get the value on the array in my $_POST.
My input :
<input name="article[]" class="form-control input-md" type="text" >
My InputFilter :
class ArticleFormFilter extends InputFilter{
public function __construct() {
$this->add(array(
'name' => 'article[]',
'required' => true,
'filters' => array(
array(
'name' => 'Zend\Filter\StripTags',
),
array(
'name' => 'Zend\Filter\StringTrim',
),
),
'validators' => array(
array(
'name' => 'NotEmpty',
),
),
));
}
}
If I do it with only one article, using article instead of article[] and no Javascript, it works of course.