Label
Labels can be automatically added to fields by adding a label attribute in the fields attribute array.
There are two ways of adding a label to your form object:
label (string name [, string for])
- name: defines the elements name attribute, should be unique in the object | required
- for: defines the labels for attribute | optional
Example:
$this->goodform->label('Your Name', 'name');
Will produce the following HTML:
<label for="name">Your Name</label>
text (array attributes)
- attributes: an associative array specifying attributes of the element.
Example:
$attr = array(
'for' => 'name',
'value' => 'Your Name',
'class' => 'my-label-class',
'title' => 'Enter your full name'
);
$this->goodform->label($attr);
Will produce the following HTML:
<label for="name" class="my-label-class" title="Enter your full name" >Your Name</label>