Form Field Definitions

Form field definitions allow you to define how a field should be rendered in a form. Every column definition in  a model can be defined and called as a chain.


public function define_form_fields($context = null)
	$this->add_form_field('title', 'left)->tab('Post')->comment('The post title');
	$this->add_form_field('url_title', 'right)->tab('Post')->renderAs('custom_partial');


  • The title field is aligned to the left, the url_title field is aligned to the right and the content field will take up the full space as default.
  • All fields will appear in a tab named Post

Field Alignment

side() sets the side of the form the field should be placed (left, right, full)

Using Tabs

enables the use of tabs in the form and specifies which tab the field should belong to

Adding Comments

comment() places a comment above or below the field

Disabling Fields

disabled() will disable the form field

Calculated Definitions

In most cases you won't need to call the renderAs() method because by default render modes are guessed automatically based on the model column definition and/or relation types.

  • tinyint columns are rendered as checkboxes (frm_checkbox).
  • float, numeric and varchar columns are rendered as text input elements (frm_text).
  • textarea columns are rendered as textarea elements (frm_textarea).
  • datetime columns are rendered as the date/time picker control (frm_datetime).
  • db_date columns are rendered as the date picker control (frm_date).
  • belongs_to relations are rendered as drop-down fields (frm_dropdown).
  • has_and_belongs_to_many relations are rendered as checkbox lists (frm_checkboxlist).

Available Definitions

Although automatic definitions are useful, however you can always override the default with the renderAs() method. The following modes are supported:


Creates a standard text input element.



Creates a standard password input element.



Creates a multiple line textarea element.



Creates a drop-down element.

$this->add_form_field('status')->renderAs(frm_dropdown)->emptyOption("<select status>");


Creates a field that can be automatically completed. 

(This feature is not complete)


Creates a set of radio buttons.



Creates a single checkbox.



Creates a set of checkboxes.

Relational usage


$this->define_multi_relation_column('rights', 'rights', 'Rights', '@name')


Relational usage with description



Creates a rich text editor (WYSIWYG)



Creates a code editor.



Creates a date / time field.



Creates a date field.



Creates a time field.

(This feature is not complete)


Creates a toggle switch element. This is basically a graphical checkbox with ON and OFF states.



Creates a record finder that let's you easily select a relationship using a popup.

    renderAs(frm_record_finder, array(
        'sorting'=>'first_name, last_name, email',
        'search_prompt'=>'Find customer by name or email',
        'form_title'=>'Find Customer',
        'prompt'=>'Click the Find button to find a customer'));


Creates a file attachment widget. You should use renderFileAs() to specify how the files should be displayed, for example, a thumbnail, or a list of images or a list of files.

    ->addDocumentLabel('Add file attachment(s)')
    ->noAttachmentsLabel('There are no files uploaded')


Creates a special widget control.

$this->add_form_field('credit_table')->renderAs(frm_widget, array(
        'credit'=>array('title'=>'Credit Amount', 'type'=>'text'),
        'cost'=>array('title'=>'Price', 'type'=>'text', 'align'=>'right')

Custom Definitions

Creates a custom field rendered with defined partial contents.

You can also override a specific column by creating a partial beginning with form_field_, for example, if the column name was title the partial file would be named form_field_title.htm and the contents could look like this: