form input fields in general
Input types
To define form elements you need to learn the input types available in clonefish.
An input definition in clonefish is nothing more but a simple associative array, where array keys are the names of the settings and array values are the actual settings. These input definition arrays are then grouped together in an array container. This is the array container used with clonefish->addElements()
, and is referred to as the form configuration most of the time.
Let's see the basics - the settings that are available for all the input types:
<?php $config = Array( 'name' => Array( 'type' => 'inputText', 'displayname' => 'Input field name', 'value' => 'default value here', 'help' => 'validation failed for this element', // layout related settings 'html' => 'class="inputfieldstyle"', 'rowlayout' => '...%element% %prefix% %postfix% etc...', // special purpose settings 'readonly' => 1 | 0, 'display' => 1 | 0, 'htmlid' => 'name1' ) ); ?>
- 'html' - you can use the
html
setting to insert anything inside the element tag: to specify eg. a CSS class, row and column sizes for a textarea, add MULTIPLE attribute for a select and so on. - 'help' - the help message for the element if the validation fails. You can use this message to override built-in validation error messages. However, you can also specify help messages for each validation of an element, which overrides this message.
- 'rowlayout' - this setting changes the layout of the form element row. The
$clonefish->layouts
array holds the element setting, which provides the default element row layout. - 'readonly' - if you'd like to keep some data together with information submitted by the user, you can use read only elements. These elements get their values only from the form configuration.
For example:
$config['userid'] = Array(
'type' => 'inputHidden',
'value' => $_SESSION['userid'],
'readonly' => true
); - 'htmlid' - elements get their HTML DOM ID from their config name (the array key). If for some reason you need to have a different ID, you can set it here. It's a nice way to avoid conflicts from other HTML elements on the same page.
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