CC6 Dynamic Dropdown for filtering table

webbusteruk 07 Dec, 2018
Wonder if anyone could help.

We are using CC6 to display a table, along with 2 dropdown filters. The options within the 2nd dropdown filter depends on what is chosen for the 1st dropdown filter. In Chronoforms6, this is achieved by using {var:somephpcode} under the 2nd dropdown's options. However, doing the same in CC6 seems to be much more difficult.

Tried using the exact same {var:somephpcode} under dropdown's options in CC6 doesn't seem to work. Is there any way to achieve this?
$options = [];
switch($this->data('course')){
case '1':
$options = ['A' => 'A'];
break;
case '2':
$options = ['B' => 'B' , 'C' => 'C'];
break;
case '3':
$options = ['D' => 'D'];
break;
default:
$options = ['N/A' => 'Please select one'];
}
return $options;
The above works when put into a [php] in CF. When put into CCv6, it does not output anything.[/php]
$options = '';
switch($this->data('course')){
case '1':
$options = 'A';
break;
case '2':
$options = 'B , C';
break;
case '3':
$options = 'D';
break;
default:
$options = 'Please select one';
}
echo $options;
When output as an echo, it correctly shows up within the dropdown's options. However, we can't make display multiple options. What format does the {var:} has to output into the dropdown's options? Array doesn't work.

[[> later: edited to add a missing ; <]]
healyhatman 07 Dec, 2018
Answer
1 Likes
So you need to create an event (have you done this?) and in this event you should have something along the lines of
{fn:somephpcode}
{view:second_dropdown}

The event name is what should go in the "Reload Event" box of the second dropdown.
ieraora 01 Apr, 2020
Thank you for this tread, there is only an error in php code, missing a ";"
This is for me the correct code:

switch($this->data('course')){
case '1':
$options = ['A' => 'A'];
break;
case '2':
$options = ['B' => 'B', 'C' => 'C'];
break;
default:
$options = ['N/A' => 'Please select one'];
}
return $options;
This topic is locked and no more replies can be posted.