I've got custom fieldset class like CustomerFieldset
. I add it to the form like this:
$someData = $this->getSomeData();
$this->add(array(
'name' => 'customfieldset',
'type' => CustomFieldset::class,
));
How to pass $someData
to this fieldset?
If you want to access the fieldset elements and set a value simply use
$form->get('customfieldset')->get('elementName')->setvalue('value');
If you want to pass other data then in your fielset create a property to hold it and create a setter.
private $propertyName;
public function setProperty($value)
(
$this->propertyName = $value;
return $this;
}
and call it from your form
$form->get('customfieldset')->setProperty($value);
Hope this points you in the right direction.