Helpful functions to render form fields for a model.

<? $search = new Search() ?>
<?= form_tag(search_path()) ?>
    <?= label($search, 'query') ?>
    <?= text_field($search, 'query') ?>
    <?= submit_tag() ?>



form_for($record_or_name, $args=null)

fields_for($record_or_name, $args=null)

label($object, $column, $text=null, $attributes=null)

Renders a label tag.

label('Product', 'in_stock');
label('Product', 'in_stock', 'In stock?');
label('Product', 'in_stock', 'In stock?', array('class' => 'available'));
label('Invoice', 'address', null, array('class' => 'invoice-address'));
label('Invoice', 'address', array('class' => 'invoice-address')); 

hidden_field($object, $column, $attributes=null)

Renders a hidden field.

text_field($object, $column, $attributes=null)

Renders a text field.

password_field($object, $column, $attributes=null)

Renders a password field.

text_area($object, $column, $attributes=null)

Renders a text area.

check_box($object, $column, $attributes=null)

Renders a check box.

Gotcha: an unchecked check box is never sent. A solution if to add a hidden field with the same name before the check box. If the box is unchecked, the hidden field's value will be sent; if checked PHP will overwrite the hidden field's value.

radio_button($object, $column, $tag_value, $attributes=null)

Renders a radio button.

select($object, $column, $options, $attributes=null)

Renders a select option field.