I want to create them as objects and then assign options, smth like:
$name = new Zend\Form\Element\Text('name');
$name->setLabel('Your name:');
$name->setRequired(true); // does not work?
$this->add($name);
How it is possible set options like "required" one there, how to set validators? Framework throws exception "No method exists" for setRequired() one.
P.S. I really don't want to use array-style, it's quite annoying when you have tons of code in one array. I mean the following:
$this->addElement('text', 'email', array(
'label' => 'Your email address:',
'required' => true,
'filters' => array('StringTrim'),
'validators' => array(
'EmailAddress',
)
));