I'm trying make to work my validation. I have data posted to controller in the format like this:
[
'property' => 'value',
'nested_property' => [
'property' => 'value',
// ...
]
]
I have divided fields/filters and form into different classes and just gather it together in the Form's controller that looks like that:
public function __construct($name, $options)
{
// ...
$this->add(new SomeFieldset($name, $options));
$this->setInputFilter(new SomeInputFilter());
}
But it doesn't work properly, looks like it just ignores nested array (or ignores everything). What have I missed?
Thank you.
You need to set up your inputfilter like the way you've setup your forms including the fieldsets if you use the
InputFilter
class.So when you've got a structure like:
1.1 NestedFieldset
1.2 AnotherFieldset
Your inputfilters need to have the same structure:
1.1 NestedFielsetInputFilter
1.2 AnotherFieldsetInputFilter
Some example code:
So the important part of configuring your inputFilter for these situations is that you need to reuse the name of your fieldset when using:
$this->add($input, $name = null)
within yourInputFilter
classes.