Field Types Overview
Every ->change_type() control xCRUD Nova Pro can render for a form field, from plain text to a live camera capture.
->change_type()
->change_type($field, $type, $length = '', $extra = []) overrides how a field renders in the create/edit form (and, for types like select, how its value is displayed in inline-edit too). Without a call, a field's type is inferred from its database column type.
| Parameter | Type | Default | Description |
|---|---|---|---|
$field | string | - | The column to change |
$type | string | - | One of the types below |
$length | string | '' | Only meaningful for price: decimal places (default 2). Ignored by every other type |
$extra | array | [] | Options array for select/multiselect/radio/checkboxes/switch, or ['prefix' => ..., 'suffix' => ...] for price |
The type list
| Type | Description |
|---|---|
text | Plain single-line text input |
textarea | Multi-line plain-text input |
editor | Quill rich-text WYSIWYG editor, stores HTML |
select | Single-value dropdown, built from $extra's options |
multiselect | Multi-value select, stored as a comma-joined value |
radio | Radio button group |
checkboxes | Checkbox group, comma-joined value like multiselect |
switch | Explicit toggle switch - always requires exactly 2 options |
password | Masked text input (visual masking only, not a hash - stored as plain text like any other text field) |
hidden | Hidden input, excluded from inline editing, still submitted with the form |
time | Time picker (MySQL TIME columns get this automatically) |
year | Number input constrained to MySQL's YEAR range (1901-2155) |
price | Decimal input with an optional currency prefix/suffix |
file | File upload field |
image | Image upload with resize/crop/watermark options |
video | Video upload field |
camera | Live camera capture (photo), stored like image |
See File & Image Uploads and Media, Camera & Video Uploads for the full option set on file/image/video/camera.
Example: a select field
$extra accepts a plain list (value = label), a value=>label map, or a list of [value, label] pairs:
$xcrud->change_type('status', 'select', '', [
'a' => 'Active',
'i' => 'Inactive',
]);
Example: a price field
$length sets decimal places, $extra sets a currency prefix/suffix:
$xcrud->change_type('unitPrice', 'price', '2', ['prefix' => '$']);