Forums

event switcher

kraadde 10d ago

Max,

I have trouble solving one issue.

I have set php80 as follows:

$options = [

['value' => '{data:datum_1}', 'text' => '{data:datum_1}'],

['value' => '{data:datum_2}', 'text' => '{data:datum_2}']

];

return $options;

a checkboxes group datum_teiln with dynamic option set as {var:php80}

The field works as expected and allows the user to choose one or both options and store the [datum_teiln]

In case the user choose both options, I want to open a second dropdown form field for the user to select his preferred option.

For this, I have, before the event switcher, issued a php84 action as follow:

$selectedDates = explode(',', $form->data['datum_teiln']);

if (count($selectedDates) === 2) {

return 'hide'; // Event Switcher hides field

} else {

return 'show'; // Event Switcher shows field

}

In the 'show' event of the event switcher, I have another php82 action:

$options = [];

if (!empty($form->data['datum_teiln'])) {

$selectedDates = explode(',', $form->data['datum_teiln']);

if (count($selectedDates) === 2) {

// Dropdown show the selected dates

$options[] = ['value' => $selectedDates[0], 'text' => $selectedDates[0]];

$options[] = ['value' => $selectedDates[1], 'text' => $selectedDates[1]];

} else {

// in the case only one date is selected kepp it empty

return [];

}

}

return $options;

as well as the dropdown datum_vorz with the dynamic option set as {var:php82}

this is not working at all.

Can you suggest any solution?

Max_admin 10d ago
Answer

There is no $form variable in ChronoForms8, you should use $this

Also do NOT use shortcodes in PHP, example: {data:datum_2}, instead you should use PHP:

$this->data("datum_2")

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
You need to login to be able to post a reply.