I have following Code in "Custom Code" Event defined as "Controller":
How can I applay this array to a "Drop Down" element?
Any advise?
Thanks for any help
<?php
date_default_timezone_set("Europe/Zurich");
$startJahr = date('Y') ;
$startJahr = $startJahr - 4;
$endJahr = $startJahr - 96;
$form->data['jahre'] = array();
for ($i = $startJahr; $i >= $endJahr ; $i--) {
$form->data['jahre'][$i] = $i;
}
?>
How can I applay this array to a "Drop Down" element?
Any advise?
Thanks for any help
Hi le5,
If you change the format of your data a little then you can use the Dynamic Data tab on a drop-down element. This requires the data to be in this format:
If you alter your code to be like this:
Note: you don't have to use 'text' and 'value' as the labels and they don't have to be the same.
Bob
If you change the format of your data a little then you can use the Dynamic Data tab on a drop-down element. This requires the data to be in this format:
array(
[0] => array( 'value' => 'some_value', 'text' => 'some_text' ),
[1] => array( 'value' => 'some_other_value', 'text' => 'some_other_text' ),
. . .
);
If you alter your code to be like this:
<?php
date_default_timezone_set("Europe/Zurich");
$jahr = date('Y') ;
$form->data['jahre'] = array();
for ($i = $jahr - 4; $i >= $jahr - 96; $i--) {
$form->data['jahre'][] = array( 'value' => $i, 'text' => $i);
}
?>
Then use 'jahre', 'value' and 'text' in the Dynamic Data settings.
Note: you don't have to use 'text' and 'value' as the labels and they don't have to be the same.
Bob
This topic is locked and no more replies can be posted.