/

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.

ParameterTypeDefaultDescription
$fieldstring-The column to change
$typestring-One of the types below
$lengthstring''Only meaningful for price: decimal places (default 2). Ignored by every other type
$extraarray[]Options array for select/multiselect/radio/checkboxes/switch, or ['prefix' => ..., 'suffix' => ...] for price

The type list

TypeDescription
textPlain single-line text input
textareaMulti-line plain-text input
editorQuill rich-text WYSIWYG editor, stores HTML
selectSingle-value dropdown, built from $extra's options
multiselectMulti-value select, stored as a comma-joined value
radioRadio button group
checkboxesCheckbox group, comma-joined value like multiselect
switchExplicit toggle switch - always requires exactly 2 options
passwordMasked text input (visual masking only, not a hash - stored as plain text like any other text field)
hiddenHidden input, excluded from inline editing, still submitted with the form
timeTime picker (MySQL TIME columns get this automatically)
yearNumber input constrained to MySQL's YEAR range (1901-2155)
priceDecimal input with an optional currency prefix/suffix
fileFile upload field
imageImage upload with resize/crop/watermark options
videoVideo upload field
cameraLive 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' => '$']);