Login Retreive lost passwordRegister
Search

Manual  /  Functions  /  Other functions  /  LinkSelectFields

LinkSelectFields
LinkSelectFields (
string $filename
string $fields
string ...
)

Arguments:

Name Description
$filename The name of the file where the field's values are loaded in
$fields The name of the first selectfield
... More names of the selectfields...

Description:

With this function you can link certan selectfields. So you can load specific values in selectField B which are linked to the selected value of field A.

NOTE: To avoid a known bug, make sure you call this function just before flush() (after all fields!)

NOTE: Don't use this in a multipaged form, it wil give javascript errors

With this function you can make 2 ore more(!) linked selectFields. After an item is selected in the first selectfield, your script is requested with the selected item. Now you have to generate a list of values for the child selectfield. FormHandler put's this values in the selectfield and let the user select an item.

In your script, you will get 3 arguments trough the $_POST array:

  • linkselect: Always true

  • filter: The selected item in the parent field. You should use this value as a filter for the new values for the child field

  • field: The field which values you should now load. (So not the fieldname of the parent field!!!)



In your script you can set the new options for the field with the static function setDynamicOptions:
FormHandler::setDynamicOptions( $options, $useArrayKeyAsValue );

The first argument ($options) has to be an array of items which should be set. The second argument represents if we have to use the array key's as the values for the field (default). If not, set this argument to false.

Example

click here and click here

<?

//Todo.. database option example

?>

See also: SetDynamicOptions

Latest change: 07 October 09 / 15:27

Comments

powered by PHP-GLOBE   © 2004 - 2024 FormHandler. All rights reserved.   -   Open source license