Dependency validation example
Validating a field depending on an other field has never been that easy! Just define the logic, and Clonefish takes care of all the details!
The example below is for the thirsty developer: some drink must be selected. Play with it!
The rules if you just don't get it from the help messages: users selecting tea must choose a flavour and addons, otherwise must select coffee with an addon or choose something else using the last select in the form.
The last select contains an "emtpy" option, which is okay if you select tea or coffee - if you didn't, you must choose another option (this is done with a value based number validation, check the configuration!).
The live form - submit it!
Data dump
Below are the dumps of some PHP variables - submit the form to see the changes!
Contents of the $_POST array: $_POST = array ( )
Results of a $clonefish->getElementValues() call: array ( 'wanttea' => NULL, 'teaflavor' => NULL, 'wantcoffee' => NULL, 'addons' => '', 'custom' => NULL, )
There are cases when the above arrays are different. This is not a bug, but a feature: clonefish was written to help with everyday form hassles (like avoiding the missing value of an unchecked checkbox or compiling the whole date string from date selector fields).
form validation for developers!
clonefish is a proven, mature form generator class that helps PHP developers to create, validate and process secure, flexible and easy-to-maintain formslearn more