Skip to content
This repository has been archived by the owner on May 2, 2021. It is now read-only.

Form field detection

2278766732 edited this page Jan 26, 2013 · 2 revisions

Models have an render_form method available. When columns are not explicitly specified in the $columns parameter a detection algorithm will look for a suitable default. This page explains which fields will be used when.

Text input

A TextField will be used for when the column has a char, tinytext or varchar data type in the database.

For the larger text types text, mediumtext and largetext the TextAreaField will be used. Note that unless the PHP model explicitly applies the no_html validation rule, this will create a WYSIWYG HTML editor.

Date fields

A date field will create a DatePickerField. And datetime and timestamp will create a DateTimeFieldPicker.

Radio controls

An enum field will be rendered as a RadioField, rendering a group of radio controls. However when the enum has more than 4 options, it will be a SelectField instead.

Select fields

An enum field that has more than 4 options will be a SelectField. When it has fewer options it will be a RadioField.

Checkbox controls

boolean, bit(1) and tinyint(1) fields will be single CheckboxField's.

A set field will be a CheckboxField that outputs a checkbox for each possible value in the set. The name attributes will be an array. For example:

<!--
Column name is "status".
Set exists of "admin,verified,banned".
-->
<input type="checkbox" name="status[admin]"> Is admin.<br>
<input type="checkbox" name="status[verified]"> Is verified.<br>
<input type="checkbox" name="status[banned]"> Is banned.

Numeric input

A NumberField or will be used for the int, tinyint, smallint, mediumint and bigint database columns. And a DecimalField will be used for float, double, decimal and real columns.

Hidden fields

A field that is a primary key with auto_increment enabled will be a HiddenField.

Clone this wiki locally