I have a complex form that incorporates a few repeater areas which I have successfully configured to both load and save data. I also have configured some dynamic dropdowns that function as expected. So far, so good!
Now I am trying to configure some dynamic dropdowns inside of a repeater area. Unfortunately I am unsure of how to get this to work. There doesn't seem to be any way to use the Reload event in the case of a dropdown repeater as the target dropdown doesn't exist when a selection is made in the initial dropdown. In addition, the dynamic nature of the field names and field ids does not make it easy to target a specific element. To make this even more complex, I am interested in displaying up to seven drop downs in the repeater area with the previous dropdowns' selections influencing the remaining dropdowns - specifically, I want to eliminate previously chosen options from future dropdown lists (if I choose option 1 in dropdown 1, then option 1 should not appear in any subsequent dropdown lists - if I choose option 2 in dropdown 2, then option 1 and 2 would be eliminated from the third dropdown and so on....)
Thanks in advance for any information or clever solutions to this problem!
John
Now I am trying to configure some dynamic dropdowns inside of a repeater area. Unfortunately I am unsure of how to get this to work. There doesn't seem to be any way to use the Reload event in the case of a dropdown repeater as the target dropdown doesn't exist when a selection is made in the initial dropdown. In addition, the dynamic nature of the field names and field ids does not make it easy to target a specific element. To make this even more complex, I am interested in displaying up to seven drop downs in the repeater area with the previous dropdowns' selections influencing the remaining dropdowns - specifically, I want to eliminate previously chosen options from future dropdown lists (if I choose option 1 in dropdown 1, then option 1 should not appear in any subsequent dropdown lists - if I choose option 2 in dropdown 2, then option 1 and 2 would be eliminated from the third dropdown and so on....)
Thanks in advance for any information or clever solutions to this problem!
John
That's going to require a bunch of custom code sorry. CF doesn't have the ability to dynamically load an arbitrary number of fields based on an arbitrary number of selections.
Thanks hh! I was pretty sure this was going to involve coding - I just wanted to make sure I wasn't missing something obvious.
John
John
For anyone trying to accomplish this, it is possible using the following setup:
1. Configure your dropdown as per usual for dynamic values.
2. EDIT: be sure to set up the Reload Event (under the Advanced tab) of the dropdown to include the repeater key (ex. {var:area_repeater11.key}) as a URL parameter, so that you can identify that particular field in the next step (your reload event would look like this: reload_field_event_name&field_id={var:area_repeater11.key}).
3. Instead of using an event to return the {view:FIELD_IDENTIFIER}, use an event with a PHP action to return the entire HTML of the dropdown (you can use your browser's developer tools to copy the entire HTML node and paste it). Use a PHP foreach or other loop to iterate over the options you want to display.
When the field is reloaded, it will display your new custom HTML with your new options instead of trying to simply load new options into the existing dropdown.
1. Configure your dropdown as per usual for dynamic values.
2. EDIT: be sure to set up the Reload Event (under the Advanced tab) of the dropdown to include the repeater key (ex. {var:area_repeater11.key}) as a URL parameter, so that you can identify that particular field in the next step (your reload event would look like this: reload_field_event_name&field_id={var:area_repeater11.key}).
3. Instead of using an event to return the {view:FIELD_IDENTIFIER}, use an event with a PHP action to return the entire HTML of the dropdown (you can use your browser's developer tools to copy the entire HTML node and paste it). Use a PHP foreach or other loop to iterate over the options you want to display.
When the field is reloaded, it will display your new custom HTML with your new options instead of trying to simply load new options into the existing dropdown.
I have it sorted now.
1) All your repeater fields need to be named correctly, so that would be for example
ALTHOUGH I just realised this works fine for autocomplete dropdowns, but not for dynamically reloaded dropdowns. Damn.
1) All your repeater fields need to be named correctly, so that would be for example
group[{var:repeater_area#}][leader]2) In your reload event, first thing you need is a PHP block with
return array_values($this->data("group.[n].leader"))[0];Then in your read data action, you would use {var:php_block_name} in place of the {data:} you would usually use.
ALTHOUGH I just realised this works fine for autocomplete dropdowns, but not for dynamically reloaded dropdowns. Damn.
This topic is locked and no more replies can be posted.