-
Notifications
You must be signed in to change notification settings - Fork 1
Form field detection
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.
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.
A date
field will create a DatePickerField
. And datetime
and timestamp
will create a DateTimeFieldPicker
.
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.
An enum
field that has more than 4 options will be a SelectField
. When it has fewer options it will be a RadioField
.
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.
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.
A field that is a primary key with auto_increment
enabled will be a HiddenField
.