Form Input - Standard Control
Standard controls map directly to HTML5 input elements. They are the basic building blocks for forms.
Text
$form->addField()->setLabel('Name')->addTextControl('name')
->setValue('John Doe')
->setPlaceholder('Enter name...');
Password
$form->addField()->setLabel('Password')->addPasswordControl('password')
->setPlaceholder('Enter password...')
->setToggleVisibility(true);
$form->addField()->setLabel('Email')->addEmailControl('email')
->setValue('user@example.com');
Number
$form->addField()->setLabel('Quantity')->addNumberControl('qty')
->setValue(1);
Textarea
$form->addField()->setLabel('Description')->addTextareaControl('description')
->setValue('Some long text...');
Hidden
$form->addHiddenControl('user_id')->setValue(123);
CSRF
Adds a hidden CSRF token field for form security:
$form->addCsrfControl();
Select
Static dropdown select:
$form->addField()->setLabel('Role')->addSelectControl('role')
->setList([
'admin' => 'Administrator',
'user' => 'User',
'guest' => 'Guest',
])
->setValue('user');
Checkbox
$form->addField()->setLabel('Active')->addCheckboxControl('is_active')
->setValue(1);
Checkbox List
Multiple checkboxes from a list:
$form->addField()->setLabel('Permissions')->addCheckboxListControl('permissions')
->setList([
'read' => 'Read',
'write' => 'Write',
'delete' => 'Delete',
]);
Radio
$form->addField()->setLabel('Gender')->addRadioControl('gender')
->setValue('male');
Radio List
$form->addField()->setLabel('Plan')->addRadioListControl('plan')
->setList([
'basic' => 'Basic',
'pro' => 'Professional',
'enterprise' => 'Enterprise',
]);
File
$form->addField()->setLabel('Document')->addFileControl('document');
Image
$form->addField()->setLabel('Photo')->addImageControl('photo');
Date
$form->addField()->setLabel('Birthday')->addDateControl('birthday')
->setValue('2000-01-01');
Time
$form->addField()->setLabel('Start Time')->addTimeControl('start_time');
Range
$form->addField()->setLabel('Volume')->addRangeControl('volume');
Label
Display-only field (non-editable):
$form->addField()->setLabel('Status')->addLabelControl()
->setValue('Active');
Common Methods
All controls share these methods:
| Method | Description |
|---|---|
setValue($value) |
Set the control value |
setName($name) |
Set the input name attribute |
setDisabled($bool) |
Disable the control |
setReadonly($bool) |
Make the control read-only |
setPlaceholder($text) |
Set placeholder text (where supported) |
addValidation($name, $value) |
Add client-side validation rule |