A little something about the Form Helper…

Just a quick pointer about the form helper usage…

If you don’t like the default output of $form->input();

echo $form->input('SomeModel.some_field');

//which produces:
<div class="input text">
   <label for="SomeModelSomeField">Some Field</label>
   <input name="data[SomeModel][some_field]" type="text" value="" id="SomeModelSomeField" />
</div>

Mainly the div’s, it produces, you can of course turn them off by using:

echo $form->input('SomeModel.some_field', array('div'=>false));

//which produces:
<label for="SomeModelSomeField">Some Field</label>
<input name="data[SomeModel][some_field]" type="text" value="" id="SomeModelSomeField" />

But you can also specify an alternative wrapper tag:

echo $form->input('SomeModel.some_field', array('div'=>array('tag'=>'li')));

//which produces:
<li class="input text">
   <label for="SomeModelSomeField">Some Field</label>
   <input name="data[SomeModel][some_field]" type="text" value="" id="SomeModelSomeField" />
</li>

P.S I believe it was Mark Story, who’ve pointed this trick out to me. So thank him! ;)

%d bloggers like this: