I just tried creating a form that uses the taxonomy_manager_tree element type with #multiple == FALSE (radio buttons instead of checkboxes), but when I submitted it, nothing was selected.

Upon looking at the code, I saw that the theme function theme_taxonomy_manager_tree_radio() was recently changed in this issue http://drupal.org/node/1103812, but otherwise still mostly consisted of code copied from the Drupal 6 theme_radio() function.

I also noticed that the function taxonomy_manager_tree_validate(), which finds selected terms and injects them into $form_state, expects a single non-array value in $form["#value"] when using radios, but this is not the case.

I updated the theme function for radio buttons to be more like the Drupal 7 version of theme_radio(), and this allows information about the selected term to appear in $form['#value'] -- I think the '#name' element of the radio buttons was being set incorrectly.

I also added code in taxonomy_manager_tree_validate() to get the selected term by calling _taxonomy_manager_tree_get_selected_terms(), even when '#multiple' == FALSE (but it then makes sure only a single term was selected).

This fixes the problem for me - and I'm now able to use the form element with #multiple == FALSE.

Comments

mh86’s picture

Status: Needs review » Fixed

Thanks for the patch, I've just committed it with a few changes:
- removed whitespaces
- simplified code in taxonomy_manager_tree_validate()
- updated theme function for checkboxes

you can see the diff at http://drupalcode.org/project/taxonomy_manager.git/commitdiff/58c1f62?hp...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.