|
Size: | 17186 |
Storage flags: | no_autoload,compress/gzip (21%) |
Zend\Form\Element is a base class for all specialized elements and Zend\Form\Fieldset.
Basic Usage
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);
|
Public Methods
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 label specific options.
Return the label specific options.
Return type: | array |
---|
Set options for an element. Accepted options are: label, label_attributes", label_options, which call setLabel, setLabelAttributes and setLabelOptions, respectively.
Get defined options for an element
Return type: | array |
---|
Return the specified option, if defined. If it’s not defined, returns null.
Return type: | null|mixed |
---|
Set a single element attribute.
Retrieve a single element attribute.
Return type: | mixed |
---|
Remove a single attribute
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 |
---|
Remove many attributes at once
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.