I have form created/called in controller in this way:
class MyController extends AbstractActionController {
function IndexAction() {
$form = $this
->getServiceLocator()
->get('FormElementManager')
->get('MyForm',['option1'=>123);
}
}
And next - In form i have access to passed options:
class MyForm extends Form implements ServiceLocatorAwareInterface
{
use ServiceLocatorAwareTrait;
public function init()
{
$option1 = $this->getOption('option1'); // I have here "123" !!!
$this->add(
[
'name' => 'Child',
'type' => 'Zend\Form\Element\Collection',
'options' => [
'label' => 'Child',
'count' => 1,
'should_create_template' => true,
'allow_add' => true,
'template_placeholder' => '__placeholder__',
'target_element' => [
'type' => 'MyFieldset',
],
],
]
);
}
}
But in fieldset saddly - no:
class MyFieldset extends Fieldset implements ServiceLocatorAwareInterface
{
use ServiceLocatorAwareTrait;
public function init()
{
$option1 = $this->getOption('option1'); // Empty :(
}
}
So - how to achieve access to "option1" in fieldset?