-
Notifications
You must be signed in to change notification settings - Fork 13
Customizing form fields
Coackroach edited this page Jan 19, 2020
·
2 revisions
You can customize the form fields by replacing the fields with the widgets OR change the layout to totally your desired layout, below are a few examples of customizing the fields like,
- disable a single field from showing
- rendering a text-area field
- rendering a simple drop-down
- rendering radio button list
- Using a widget instead of a field, i.e
DatePicker
use buttflattery\formwizard\FormWizard;
use yii\jui\DatePicker;
echo FormWizard::widget([
'steps' => [
[
'model' => $shootsModel,
'title' => 'My Shoots',
'description' => 'Add your shoots',
'formInfoText' => 'Fill all fields',
'fieldConfig' => [
'updated_at'=>false, //hide a specific field
'description' => [
'options' => [
'type' => 'textarea',
'class' => 'form-control',
'cols' => 25,
'rows' => 10
]
],
'shoot_type' => [
'options' => [
'type' => 'dropdown',
'itemsList' => [0 => 'Indoor', 1 => 'Outdoor'], //the list can be from the database
'prompt' => 'Please select a value',
]
],
'active' => [
'labelOptions' => [
'label' => 'Activate User'
],
'options' => [
'type' => 'radio',
'itemsList' => [0 => 'No', 1 => 'Yes'], // the radio inputs to be created for the radioList
]
],
'created_at' => [
'widget' => DatePicker::class, //widget class name
'options' => [ // you will pass the widget options here
'options' => [
'placeholder' => 'Select a Date',
'id' => 'my-datepicker',
'class' => 'form-control'
],
'dateFormat'=>'short'
],
]
]
],
[
'model'=>$shootTagModel,
'title'=>'Shoot Tags',
'description'=>'Add Shoot Tags',
'formInfoText'=>'Fill all required fields'
]
]
]);
- Get Running with Minimal Options
- Disable ActiveForm Validation
- Enable Ajax Validation
- Add Custom Buttons
- Widget Constants
- Customizing Form Fields
- Configuring File Uploads
- Custom Field Order
- Single Model Across Steps
- Multiple models in a single step
-
Tabular Steps-(New)
- Working With Widgets
- Limiting Rows
- Dependent Inputs Since v1.7.2
- Skip-able Step-(Since v1.5.0)
- Enable Preview Step-(New)
- Group Fields-(New)
- Enable Form Persistence-(New)
- Enable Edit Mode - (Since v1.6.4)