Search code examples
cakephpcakephp-2.0cakephp-2.1cakephp-2.2

Chaging the label position for an input at CakePHP 2.2


CakePHP usually place labels before the input, so doing this:

echo $this->Form->input('subject');

We obtain this:

<div class="input text required">
    <label for="TicketSubject">Subject</label>
    <input name="data[Ticket][subject]" maxlength="255" type="text" id="TicketSubject">
</div>

Is there any way to place the label after the input to obtain this?

<div class="input text required">
    <input name="data[Ticket][subject]" maxlength="255" type="text" id="TicketSubject">
    <label for="TicketSubject">Subject</label>
</div>

Thanks.


Solution

  • The proper way is using the the 'format' option.

    $this->Form->input('subject', array(
        'format' => array('before', 'input', 'between', 'label', 'after', 'error')
    ));
    

    Didn't anyone read the API :)