Hi everybody,
I've been searching and searching for almost 20 hours now without any result...
I have a website containing a Ctools form wizard with 3 steps. In one of the steps I need to replace 2 fields (language + extra field, in separate fieldsets), based on an AHAH enabled country-dropdown.
You can view the situation in this screenshot: http://dev.wenskaartenshop.be/shipping_form.png
I have other forms with AHAH functionality, using the Ahah-Helper module, but this module (and the core AHAH mechanisms) lets you only replace one "path" per AHAH field.
Question #1: Is there a way in Drupal so that I can replace 2 "elements" simultaneously on my page, based on a dropdown change?
Question #2: It seems that my AHAH register call is not setting the correct include path for my form-file include, because of the Ctools Wizard form-wrapper... Is there a way to fix this?
Thanks in advance!!!
/Kim
Comments
I need the same thing to be done
Hi,
I am searching for the same thing to do..
is there any solution for that please?
It seems it is not possible
It seems it is not possible to replace 2 elements simultaneously, unless you put them in the same parent.
You can accomplish this by wrapping your form elements with a markup parent, using #prefix and #suffix, and using that ID as replacement path.
This will render your form fields as normal (because it's invisible markup, instead of a fieldset parent), submit them as they weren't in a parent (because of #tree = FALSE).
Another solution, which I used, was to create a JS function, which "filters" the second option field values, based on the first option field value.
This solution requires some different components:
1. Initially populate both select fields with all possible values in your Drupal MYFORM_form() function
2. Create some sort of array tree, which can be rendered to JSON, and injected into Drupal.settings.YourFormSettings
Values 1st dropdown:
Values 2nd dropdown in JSON:
Initial second dropdown values:
Create a function which hooks into the .change() event of the first dropdown, and reads the selected value:
PHP in your form function:
JS in your form function:
This will automagically repopulate the second dropdown, based on the first dropdown, and make Drupal think it's a valid option none the less.