form_label()

form_label([$label_text = ''[, $id = ''[, $attributes = array()]]])

Parameters:
  • $label_text (string) – Text to put in the <label> tag
  • $id (string) – ID of the form element that we’re making a label for
  • $attributes (string) – HTML attributes
Returns:

An HTML field label tag

Return type:

string

Lets you generate a <label>. Simple example:

echo form_label('What is your Name', 'username');
// Would produce:  <label for="username">What is your Name</label>

Similar to other functions, you can submit an associative array in the third parameter if you prefer to set additional attributes.

Example:

$attributes = array(
        'class' => 'mycustomclass',
        'style' => 'color: #000;'
);

echo form_label('What is your Name', 'username', $attributes);
// Would produce:  <label for="username" class="mycustomclass" style="color: #000;">What is your Name</label>
doc_CodeIgniter
2016-10-15 16:32:19
Comments
Leave a Comment

Please login to continue.