I have this for a form
$this->add(array(
'name'=>'username',
'type'=>'Text',
'options'=>array(
'label' => 'Username',
)
));
$this->add(array(
'name'=>'password',
'type'=>'Password',
'options'=>array(
'label' => 'Password',
)
));
and
echo $this->formCollection($form);
This are obviously just the relevant parts of the code. The output is as follows:
<fieldset ><label><span>Username</span><input type="text" name="username" value=""></label><label><span>Password</span><input type="password" name="password" value=""></label>
Is there any way to either put each row into a paragraph or to separate all the rows with line breaks? I read something about Decorators, but I'm not sure that was Zend Framework Version 2 and I don't know how to apply this to formCollection, if it was.
Best thing to do is override the formRow
helper with your own version that outputs the markup you want. I wrote a little lib that does just this, feel free to use it or copy the approach.
Define your own helper: https://github.com/tfountain/tf-form/blob/master/src/TfForm/Form/View/Helper/FormRow.php and then update your module config to use it: https://github.com/tfountain/tf-form/blob/master/config/module.config.php