I’m trying to create a couple of dropdowns in drupal 7, I have a series of tasks relating to a particular sandbox. user selects the sandbox and gets a select populated with the tasks for that sandbox which he then selects again.
the dependant dropdown needs to have each task in an array then all those arrays, heres the hardcode version…
$optionsB = array(
t('level 1') => drupal_map_assoc(doTasksQuery('level 1')),
t('level 2') => drupal_map_assoc(doTasksQuery('level 2')),
t('level 3') => drupal_map_assoc(doTasksQuery('level 3')),
);
doTasksQuery() returns the task list for each level using drupals db_query().
How can I make this dynamic to allow a variable amount of levels? as it is they are fixed. I also have another method to return the level names which returns an php associative array and I’d rather use that to populate the key values than hard coding them.
Thanks for looking
If you have the level names in an array $levels: