|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| „multititle“ | The keys used here will be used as titles if this field is beeing multiedited. Several keys are possible, separated by comma. |
| „pre“ | This function is applied before the value is rendered in the html form. |
| „post“ | After submitting the form the value for this field will be postprocessed by this function to ensure the value is in a given range and doesn't break the database. This a good place to work with format_userinput(). |
| „list“ | This is the way the value is being processed before it gets displayed in the list. |
Most often you just want to prepare the value for HTML output which is handled by the function ko_html(). In this case you can just enter "ko_html" for "pre" e.g.
For "post" you might want to use one of the formatings available in the function format_userinput(). You can just pass the mode to "post", so you don't have to write the whole function call "format_userinput("@VALUE@", "js")" all the time.
The possibilities of these functions are almost endless because it is also possible to call any external function. The string "@VALUE@" will get substituted with the actual value from the database or the form submission.
The following example demonstrates this with a date field:
"startdatum" => array(
"pre" => "sql2datum('@VALUE@')",
"post" => "sql_datum('@VALUE@')",
"form" => array(...),
),
If it is not enough to work on the submitted value, you can call any function which will have more information available for postprocessing:
"nachname" => array(
"post" => (in_array("nachname", $COLS_LEUTE_UND_FAMILIE) ? "FCN:ko_multiedit_familie" : ""),
"form" => array(...),
),
First of all this postprocessing is only performed if the field „nachname“ is found in the given array. If this is the case, then you are able to call a function by specifing its name as „FCN:NameOfFunction“. This function will get two arguments the first being a reference to the submitted value and the second beeing an array with the following content:
array("table" => $table, "col" => $col, "id" => $id);
Where $table, $col and $id stand for the name of the table, the column and the id beeing worked on.
You can use all types defined in the general form template /templates/ko_formular.tpl for the different db columns. The following table shows the most common used types. The third column shows the additional setting that can be made for the different types.
| GENERAL | These can be set for every field | - params (string): html parameter that are passed to the form field - new_row (Boolean): Forces the next field to be on a new line - value: Current value - name: The html name of the input field. Is autogenerated at the creation of the form in the form koi[TABLE][col][id]. id is 0 for a new entry. - desc: The field's label. If not set, it will be assigned from the LL value kota_TABLE_FIELD |
| text | Input field | - params: e.g. 'size=“11“ maxlength=“11“' |
| textplus | This is basically an input field, but there is a select field presented for easier selection of already made entries. | - params: e.g. 'size=“0“' for the select field - params_PLUS: Parameters for the textfield to the right of the select. e.g. 'size=“60“ maxlenght=“200“' |
| textarea | Textarea | - params: e.g. 'cols=“60“ rows=“5“' |
| color | Input field with color chooser popup | - params: e.g. 'size=“10“ maxlength=“7“' |
| file | File upload | - params: e.g. 'size=“60“' The file will be saved as /my_images/kota_TABLE_COLUMN_ID.EXT |
| select | Single select | - params: e.g. 'size=“0“' - values: Array with the values for the available options - descs: Array with the labels for the available options |
| doubleselect | Multiple select with two select boxes | same as select plus - avalues: Array with the values for the selected options - adescs: Array with the labels for the selected options - avalue: Comma separated list of the selected values - js_func_add: JS function to be called upon selection of an entry. Defaults to double_select_add. |
| peopleselect | Doubleselet to choose one or more people from ko_leute | same as doubleselect The adminfilters will be applied, so a user will only see the people he has access to. |
| dynselect | A dynamic select with size > 1 which can change the list items using an AJAX call. Will be rendered as optgroup-select when multiediting. |
Same as select |
| dyndoubleselect | As dynselect but multiple values may be selected using a second select holding the selected entries. | Same as doubleselect |
The _form_layout array can be used to precisely define the layout of a single-edit form for a table. It is a field in the $KOTA array of the respective table. Let's for example consider a table called 'car'. Then the _form_layout of that table could be defined the following way:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | $KOTA['car']['_form_layout'] = array(
'general' => array(
'sorting' => 10,
'groups' => array(
'general' => array(
'sorting' => 10,
'group' => FALSE,
'rows' => array(
10 => array('manufacturer' => 6, 'model' => 6),
20 => array('age' => array('colspan' => 6, 'onOwnRow' => TRUE)),
30 => array('description' => 12),
),
),
),
),
'interior' => array(
'sorting' => 20,
'groups' => array(
'electronics' => array(
'sorting' => 10,
'group' => TRUE,
'rows' => array(
10 => array('navigation' => 6, 'radio' => 6),
20 => array('media_system' => array('colspan' => 6, 'onNewRow' => TRUE)),
),
),
'seats' => array(
'sorting' => 20,
'group' => TRUE,
'appearance' => 'success',
'rows' => array(
10 => array('heatable' => 6, 'customizable' => 6),
),
),
),
),
'technical_data' => array(
'sorting' => 30,
'groups' => array(
'engine' => array(
'sorting' => 10,
'group' => TRUE,
'rows' => array(
10 => array('hp' => 6, 'torque' => 6),
20 => array('co2' => 6, 'fuel' => 6),
),
),
'driving_performance' => array(
'sorting' => 10,
'group' => TRUE,
'rows' => array(
10 => array('from_0_to_100' => 6, 'max_speed' => 6)
)
)
),
),
'_default_cols' => 6,
'_default_width' => 6,
'_ignore_fields' => array('color'),
);
|
In the following, the different elements and attributes of this toy form_layout will be explained.
The koFormLayoutEditor class offers functions for manipulating the _form_layout arrays. This can come in handy if you want to add/remove fields from within a plugin. Consider lines 10 and 24 of the example _form_layout definition: there the value of the array entry is not just the width of the field but an array. This array can contain the following entries:
Once the KOTA is configured correctly, the generation of the form is a matter of one function call, here you see the example to edit a smallgroup:
$form_data = array(„title“ => $title, „submit_value“ => $submit_value, „action“ => $action);
ko_multiedit_formular("ko_kleingruppen", "", $id, "", $form_data);
In the array $form_data some values are set to be used in the form:
The function itself has following parameters:
| $table | db table |
| $columns=““ | the columns to be edited. All of them if empty |
| $ids=0 | the ids of the entries to be edited. 0 for a new entry |
| $order=““ | define the column and ASC or DESC for the ordering of the different entries |
| $form_data=““ | values as specified above |
| $return_only_group=FALSE | Boolean that lets you receive the $group array as return value, which enables you to add other input fields - not defined in KOTA - and pass the adapted $group array to the form template. |
After the submission of the form the function kota_submit_multiedit() handles the whole postprocessing and storing in the database. The function accepts 3 arguments
| ©Renzo Lauper, CH-5000 Aarau, All rights reserved | Datenschutzerklärung |