Reputation: 13296
When creating forms or fieldsets in Zend Framework 2, I use the add()
method to add fields to it. Typically, this looks as unspectacular as this:
$this->add(array(
'type' => 'text',
'name' => 'fieldName',
'options' => array(
'label' => 'Some Label'
),
));
That code has been copied from the Reference Guide which is full of helpful examples, but unfortunately it doesn't list all available array keys.
Of course I've already checked the API docs, but that only tells me
$flags could contain metadata such as the alias under which to register the element or fieldset, order in which to prioritize it, etc.
which is not exactly a detailed documentation.
I also looked directly at the source, but that also didn't answer anything for me, so I am left wondering:
Is there any documentation on the available array keys when using the add()
method?
Upvotes: 1
Views: 57
Reputation: 8642
You didn't look deep enough :).
Here you go:
name
: set the name for the element. Takes precedence over the name
from element spec. If no name was specified either in the element
or in the flags array an exception is thrown as unnamed elements are
not allowed on a form.
priority
: change the order of the element among other elements. Usefull when an view helper like form
is used to render the whole
form
Please add an issue on zf2 github and I'll contribute that.
Upvotes: 1