cakephp logo

Customizing your form labels in CakePHP 1.2

If you want to customize the labels placed on forms you can assign an array to the label parameter in the $form helpers options, for example :-

Show Plain Text
PHP code
  1. echo $form->input('', array('label' => array('class' => 'Your-Class', 'text' => 'Name<span style="color:#f89e01">*</span> :'), 'size' => '25'));

The generated HTML output for the above line is :-

Show Plain Text
HTML code
  1. <div class="input required">
  2.   <label for="ContactName">Name<span style="color: rgb(248, 158, 1);">*</span> :</label>
  3.   <input type="text" id="ContactName" value="" maxlength="25" size="25" name="data[Contact][name]"/>
  4. </div>

The CakePHP documentation is getting better by the day, you can read a more comprehensive list of $form->input options now under the book section Automagic-Form-Elements.

Filed under: Cakephp  Tags: Form

0 Responses to “Customizing your form labels in CakePHP 1.2”

Sorry, comments have been closed for this post.