Hi,
I was wondering how to populate an "allowed values" of a select-list using PHP. The catch is, I was hoping to populate this list dependent on an additional select-list value within the form.
So, I have two select-lists. Select-list A allows a user to choose a department, and the second select-list B allows a user to choose a sub-department. The values of sub-department are dependent on the chosen value of department.
I suppose the information I am looking for is how to reference the chosen value of select-list A. I am building the form using CCK and am trying to avoid creating my own module, since CCK allows the user to choose an "allowed values" with PHP code.
Thanks in advanced for your time,
Jeff
Comments
Welp, further research led
Welp, further research led me to the following conclusion, for those of you struggling with the same issue:
In order to populate a form element from within the form, you cannot (repeat) affect the form from within the form using CCK. So choosing select list A cannot affect select list B. Why? Because the form is already drawn (compiled) at the point of a user editing it.
Solution: You must hunker down and write your own module using:
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html...
This will provide callbacks to affect the select list B after choosing select list A's value.
Note, there is some existing interest in combining ahah with CCK, but the best of my knowledge, it is just an idea at this moment:
http://drupal.org/node/186503
Yeah.
Solution found using a
Solution found using a mixture of a custom module and a public domain one.
After learning FormAPI for Drupal 6, and starting to work with Ahah, I would strongly recommend the following module:
http://drupal.org/project/ahah_helper. Install the demo that comes with this module (ahah_helper_demo), and learn that code. It will be beneficial use of your time.
Subscribe
Thanks for the info