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 ParameterOnly Available for "form_type"PurposeValuesSeeTODONotes
form_type
HTML Form Typetext, select, checkbox, textarea, password, link, (date, ..)https://laravelcollective.com/docs/5.2/html

name
SQL Field name



description
HTML Description of Field










valueselectHTML Select Menuarray (sql_value_1 => description_1, sql_value_2 => description_2)

ItemController -> product_id, OIDController -> snmp_type



valuecheckbox

The SQL Value to be set, when checkbox is checked,

if not set sql value for checked is assumed as 1





checkedcheckboxfor checkbox, set as checked for adding fieldstrue


urllinkneeds to be sete.g. created by route() function -> route('OID.edit', ['id' => $oid->id])ParameterController

colorlinkcan be set to change the default colordefault, primary, info, success, danger, warning, inverse, white, linkapp/extensions/FormBuilder

create

auto add prefilled field to related relation views

  • causes a hidden field in create form of the (in array) specified related models
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, indirectly1, '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-trianglesee: http://fontawesome.io/icons/


autocomplete
Define if autocomplete should be enabled and which table/column should be usedArray 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:

  • string: assign element to a or multiple class(es)
  • array: 1 => 'class 1 to show', 2 => 'class 2 to show', ..
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:

  • 'checkbox' => 'show_on_<checkbox_id>'  ⇒  field will be shown if checkbox with <checkbox_id> is checked
  • 'checkbox' => 'hide_on_<checkbox_id>'  ⇒  field will be hidden if checkbox with <checkbox_id> is checked
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