Fabrik User Manual 0



Yüklə 1,97 Mb.
Pdf görüntüsü
səhifə11/24
tarix17.09.2018
ölçüsü1,97 Mb.
#69275
1   ...   7   8   9   10   11   12   13   14   ...   24

The daddy of all validation rules! Ensures that the user has entered or selected
something.
• Error message - The message to display next to the element if the validation
fails. This text should explain why the validation failed and what steps the user
should take to remedy the error.
• Condition - A PHP expression which if returns false, means that the validation is
not run.
PHP
A customizable validation rule. Runs PHP code to test for validation success or failure
• Error message - The message to display next to the element if the validation
fails. This text should explain why the validation failed and what steps the user
should take to remedy the error.
• Condition - A PHP expression which if returns false, means that the validation is
not run.
• PHP -PHP code to run. If it returns 'true' then the validation is successful, if it
returns false then the validation fails. The element's submitted value is found in
the variable $data.
You can also return a string which can be used if the 'Match or replace' option is
set to 'replace'
• Match or Replace - If set to match then the validation behaves as normal and
on validation failure returns you to the form showing the error message. If set to
'replace' then the submitted value is replaced with the data returned from the
'PHP code' script
41


Examples:
Ensure a date elements value (stored in the value $data) is greater than anothers whose
full element name is 'tablename___elementname':
$f = JRequest::getVar('tablename___elementname');
$f = JFactory::getDate($f)->toUnix();
$data = JFactory::getDate($data)->toUnix();
return $data > $f;
Regular Expression
A customizable validation rule. Runs a Regular Expression to test for validation success
or failure
• Error message - The message to display next to the element if the validation
fails. This text should explain why the validation failed and what steps the user
should take to remedy the error.
• Condition - A PHP expression which if returns false, means that the validation is
not run.
• Regular expression - A regular expression (must start and end with /)
Uses PHP's preg_match function to determine if there is a match in the data. If
there is then validation succeeds otherwise it fails
• Match or Replace - If set to match then the validation behaves as normal and
on validation failure returns you to the form showing the error message. If set to
'replace' then the submitted value is replaced with the data contained in the field
'Replace string'
42


• Replace string - the data to replace the submitted data with if the validation
fails and 'Match or Replace' is set to 'Replace'
JavaScript
The Javascript tab allows you to add infinite JavaScript actions to your element. For each
action you have the choice between manually entering some JavaScript code, or using
the GUI to create simple interactions.
• Add - The JavaScript event that will trigger the code either specified in the Code
field or generate from the GUI options.
• Code - The Javascript to run when the specified action occurs. The variable 'this'
refers to the instance of the element plug-in class that has been attached to the
element - for example the check-box class is found in components/com_fabrik/
plugins/elements/fabrikcheckbox/javascrpt.js.
All of these classes inherit from the base element class which is location in
/components/com_fabrik/views/form/element.js
Or
• Do - The Javascript action to perform the description of each option is self
explanatory
• That - the element or group to perform the action upon.
• Is - To perform the action the value of the element must be matched with the
selection chosen here and the value entered in the last field.
e.g.
hide group1 when this == 1
will hide group one when the value of the element is 1
the inverse event would be this:
show group1 when this != 1
43


Setting Element Values With JavaScript
To consistently set the value of an element the following code can be used:
form_1.formElements.get('tablename___elementname').update('newvalue') ;
replace the '1' in 'form_1' with your form's ID.
Remember that for elements such as checkboxes, radio buttons and dropdowns
'newvalue' refers to the sub element's values and not their labels.
For checkboxes and mutliple select dropdown's you can assign mutliple selections
separated with '|-|', e.g.
form_1.formElements.get('tablename___elementname').update('newvalue|-
|anothervalue') ;
Element plug-ins
The element plug options appear when you select a plug-in from the "Element type" drop
down. Below is a description of all the standard element plug-in options.
Button
The button element has no extra options, its text is derived from the label setting, and
javascript actions can be added from within the Javascript tab. Note that a submit button
is automatically added to the form, so creating an element to do the same function is not
required.
Checkbox
The checkbox element allows you to add a group of check boxes to your form. Each
checkbox is defined in the Sub Elements section of the form
44


• Default Value - If no checkbox selected this value will be stored in the
database.
• Default Label - If no checkbox selected this value will be shown in the fabrik
table
• Element before label - If yes then the checkbox appears before its label, if no
then the checkbox appears after the label
• Options per row - The number of check boxes
Sub Elements
• Add - Press this to add in a new checkbox
• Value - The value that is stored in the database if the checkbox is selected
• Label - The label that appears next to the checkbox. Equally this label is shown
in the table view rather than the recorded value (which is stored in the database
table itself)
• Default - is the option selected as default
• Delete - Press this to delete the checkbox
• Note: you can reorder the sub elements by clicking down on the grey bar to the
side of the value field and dragging it within the list.
Add Options
45


Yüklə 1,97 Mb.

Dostları ilə paylaş:
1   ...   7   8   9   10   11   12   13   14   ...   24




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə