Zend\Form\Element is a base class for all specialized elements and Zend\Form\Fieldset.
At the bare minimum, each element or fieldset requires a name. You will also typically provide some attributes to hint to the view layer how it might render the item.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | use Zend\Form\Element;
use Zend\Form\Form;
$username = new Element\Text('username');
$username
->setLabel('Username')
->setAttributes(array(
'class' => 'username',
'size' => '30',
));
$password = new Element\Password('password');
$password
->setLabel('Password')
->setAttributes(array(
'size' => '30',
));
$form = new Form('my-form');
$form
->add($username)
->add($password);
|
Set the name for this element.
Return the name for this element.
Return type: | string |
---|
Set the value for this element.
Return the value for this element.
Return type: | string |
---|
Set the label content for this element.
Return the label content for this element.
Return type: | string |
---|
Set the attributes to use with the label.
Return the attributes to use with the label.
Return type: | array |
---|
Set options for an element. Accepted options are: "label" and "label_attributes", which call setLabel and setLabelAttributes, respectively.
Set a single element attribute.
Retrieve a single element attribute.
Return type: | mixed |
---|
Check if a specific attribute exists for this element.
Return type: | boolean |
---|
Set many attributes at once. Implementation will decide if this will overwrite or merge.
Retrieve all attributes at once.
Return type: | array|Traversable |
---|
Clear all attributes for this element.
Set a list of messages to report when validation fails.
Returns a list of validation failure messages, if any.
Return type: | array|Traversable |
---|
The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.