|
|
|
|
|
|
(Since version FH3 v1.2.4)
dbCheckBox |
dbCheckBox (
string |
$title |
string |
$name |
string |
$table |
mixed |
$fields |
string |
$extraSQL = null, |
mixed |
$validator = null, |
string |
$extra = null, |
string |
$mask = null |
) |
Arguments:
Name |
Description |
$title |
Title of the field |
$name |
Name of the field |
$table |
The table where the values of this field should be fetched from |
$fields |
String or array with the field(s) which are retrieved from the table and put into the select field. |
$extraSQL |
Some extra SQL which will be included right achter the "FROM <table>" statement. With this you can order the items, join tables, etc. |
$validator |
This can either be the name of your own validation function or the constant name of a predefined validator function. For more information about validators see Validators.
It is also possible to use a method as a validation function. In this case you should pass an array where the first item is the object and the second item the name of the method. |
$extra |
This can be extra information which will be included in the fields html tag. You can add for example some CSS or javascript. |
$mask |
With this argument you can position the field(s). In the given mask a the placeholder %field% will be replaced with the field. When the mask is full and there are still fields, the mask will be repeated. This works the same as SetMask.
When no mask is given the mask will be used which is set in the config file in the var FH_DEFAULT_GLUE_MASK. |
Description:
With this function you can populate a checkbox with values which are loaded from a table.
Example
<?php
// include the formhandler
include( 'FH3/class.dbFormHandler.php' );
// create new db formhandler object
$form = new dbFormHandler();
// set the database info (create a new connection)
$form -> dbInfo( 'database', 'table', 'mysql' );
$form -> dbConnect( 'localhost', 'username', 'password');
// new selectfield
$form -> dbCheckBox(
'Options from a table',
'saveInField',
'loadFromTable',
array( 'keyField', 'valueField' ),
' ORDER BY `valueField`',
FH_NOT_EMPTY
);
// button to submit
$form -> submitButton();
// what to do when the form is saved
$form -> onSaved( 'doRun' );
// show the form
$form -> flush();
// the function which is called when the data is saved
function doRun( $id, $data )
{
echo "Your selected value '". $data['saveInField'] ."' is saved!";
}
?>
|
Latest change: 27 June 08 / 09:58
Comments
|
|
|
|