Form Fields
Purpose
Set fields to be displayed in edit and create page.
Context
Controller Function – view_form_fields()
Example
/** * defines the formular fields for the edit and create view */ public function get_form_fields($model = null) { // label has to be the same like column in sql table return array( array('form_type' => 'text', 'name' => 'name', 'description' => 'Name'), array('form_type' => 'text', 'name' => 'ds_rate_max', 'description' => 'DS Rate [MBit/s]'), array('form_type' => 'text', 'name' => 'us_rate_max', 'description' => 'US Rate [MBit/s]'), ); }
Return
2xD Array [[field1],[field2], ...]
Field Parameters
Main Parameter | Only Available for "form_type" | Purpose | Values | See | TODO | Notes |
---|---|---|---|---|---|---|
form_type | HTML Form Type | text, select, checkbox, textarea, password, link, (date, ..) | https://laravelcollective.com/docs/5.2/html | |||
name | SQL Field name | |||||
description | HTML Description of Field | |||||
value | select | HTML Select Menu | array (sql_value_1 => description_1, sql_value_2 => description_2) | ItemController -> product_id, OIDController -> snmp_type | ||
value | checkbox | The SQL Value to be set, when checkbox is checked, if not set sql value for checked is assumed as 1 | ||||
checked | checkbox | for checkbox, set as checked for adding fields | true | |||
url | link | needs to be set | e.g. created by route() function -> route('OID.edit', ['id' => $oid->id]) | ParameterController | ||
color | link | can be set to change the default color | default, primary, info, success, danger, warning, inverse, white, link | app/extensions/FormBuilder | ||
create | auto add prefilled field to related relation views
| array e.g. \['Modem', 'SepaMandate'] | modules/ProvBase/Http/Controllers/ContractController.php | From version 2.5 | ||
init_value | if init_value is set this will be filled into form field | PhonenumberManagement, PhonebookEntry | ||||
options | directly passed through app/extensions/html/FormBuilder and then to laravelcollective html entities | https://laravelcollective.com/docs/5.2/html | ||||
space | Mark a segment of fields as finished (to colorize different parts) | 1, '1' | ||||
hidden | Hide Field in HTML, indirectly | 1, '1', 'C', 'E' | 0: always show (override other conditions) 1: always hide 'C': only hide when creating/adding 'E' : only hide when editing | |||
html | Use HTML specified HTML syntax instead of building HTML in middleware | See ModemController ->x , y | ||||
help | Show Help Message after HTML field for mouse hover | |||||
help_icon | The help icon symbol, like: fa-exclamation-triangle | see: http://fontawesome.io/icons/ | ||||
autocomplete | Define if autocomplete should be enabled and which table/column should be used | Array of length 0, 1 or 2 | e.g. in Modem, field street: []: autocomplete street with values from Modem.street ['Contract']: autocomplete street with values from Contract.street ['Contract', 'zip']: autocomplete street with values from Contract.zip | |||
select | jquery (java script) realtime based showing/hiding of fields | Use a string statement to add a field to a (or multiple) class(s) for showing and hiding them later. The element on which the selection depends / is based must be filled as array, where the key is the value of the selected element and the array value is the class to show. All other classes will be hidden. Summary:
| See ItemController from Nino Ryschawy | |||
checkbox | JQuery based realtime showing/hiding of fields based on checked/unchecked checkboxes. | Changes visibility onLoad and onChange of the correlating checkbox. Usage:
| See PhonenumberManagementController (Patrick Reichel) | |||
field_value | internally used to parse the model data (from sql) to the form fields array. e.g. firstname field could parse Günter in field_value |
this will not document native HTML options, which will be parsed directly to FormBuilder API, which could also mean directly to HTML