Skip to content

2.4 Forms Input Fields

Sximo5 edited this page Sep 19, 2017 · 11 revisions

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 .

Method Function

forms( 'param1','param2',[param3])

Params & Arguments

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)
Array Arguments

This array arguments are accepted by all input type

[
  'class'     => ''
  'attribut'  => ''
  'style'     => ''

]
Example
$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 . .


Text

Format as input form

forms( 'field','text')

Textarea

Format as input textarea form

forms( 'field','textarea')

Editor

Format as input textarea with editor wyswyg form

forms( 'field','editor')

Date

Format as input with datepicker form

forms( 'field','date')

Datetime

Format as input with datetimepicker form

forms( 'field','datetime')

Time

Format as input timeform

forms( 'field','time')

Year

Format as input year form

forms( 'field','year')

Select

Format as input select database/custom form

forms( 'field','select',[array])

Additional arguments

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 .

Example
// 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'
       ])

Upload

Format as input upload file/image form

forms( 'field','upload',[array])
Additional arguments

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.

Example
->forms('photos','upload',[
          'type'=>'image',
          'path'=>'/uploads/folder/'
       ])

Radio

Format as input radio form

forms( 'field','radio','[array]')
Additional arguments

Accepted array arguments by this type

[
  'options'     => '0:Inactive , 1:Active' // option values are separated by semicolumn 
]

options is mandatory.

Example
->forms('status','radio',['options'     => '0:Inactive , 1:Active'])

Checkbox

Format as input checkbox form

forms( 'field','checkbox')
Additional arguments

Accepted array arguments by this type

[
  'options'     => '0:Inactive , 1:Active' // option values are separated by semicolumn 
]

options is mandatory.

Example
->forms('status','checkbox',['options' => '0:Inactive , 1:Active'])