-
Notifications
You must be signed in to change notification settings - Fork 2
2.4 Forms Input Fields
First of all when you call and render the cruds , it will create automatic form input fileds based on database field type table . Of course you may want to change them into your input need .
forms( 'param1','param2',[param3])
This method required 2 or 3 parameters , depending input type . first parameter is string , second string and last is array. Each type input will have different arguments for array
parameter , depending of input type.
('field(string)','type(string),array)
This array arguments are accepted by all input type
[
'class' => ''
'attribut' => ''
'style' => ''
]
$CrudEngine->table('employees')
->forms('photos','upload',['path'=>'/uploads/photos'])
->forms('coments','editor')
->render();
The first parameteris field
table, second is type
of input then last array
parameter if any . .
Format as input form
forms( 'field','text')
Format as input textarea form
forms( 'field','textarea')
Format as input textarea with editor wyswyg form
forms( 'field','editor')
Format as input with datepicker form
forms( 'field','date')
Format as input with datetimepicker form
forms( 'field','datetime')
Format as input timeform
forms( 'field','time')
Format as input year form
forms( 'field','year')
Format as input select database/custom form
forms( 'field','select',[array])
Accepted array arguments by this type
[
'lookup' => 'tablename:tablekey:displayfield-displayfield2' // Select value from database
'options' => '0:Inactive , 1:Active' // option values are separated by semicolumn
'multiple' => 'true' // allow multiple uploads ,'true' is multiple
]
lookup
or options
are mandatory. its only allowed one , choose lookup or options .
// Select with option value from database lookup
->forms('customerNumber','select',[
'lookup' => 'customers:customerNumber:customerName'
])
// Select with custom option value
->forms('status','select',[
'options' => 'pending:Pending,shipped:Shipped,canceled:Canceled'
])
Format as input upload file/image form
forms( 'field','upload',[array])
Accepted array arguments by this type
[
'path' => '/uploads/folder/' // define folder location for uploaded file/image
'type' => 'image' // upload as `image` or `file`
'multiple' => 'true' // allow multiple uploads ,'true' is multiple
'resize' => '200' // Resize image to 200px
]
path
is mandatory.
->forms('photos','upload',[
'type'=>'image',
'path'=>'/uploads/folder/'
])
Format as input radio form
forms( 'field','radio','[array]')
Accepted array arguments by this type
[
'options' => '0:Inactive , 1:Active' // option values are separated by semicolumn
]
options
is mandatory.
->forms('status','radio',['options' => '0:Inactive , 1:Active'])
Format as input checkbox form
forms( 'field','checkbox')
Accepted array arguments by this type
[
'options' => '0:Inactive , 1:Active' // option values are separated by semicolumn
]
options
is mandatory.
->forms('status','checkbox',['options' => '0:Inactive , 1:Active'])