Closed (fixed)
Project:
Taxonomy Term Reference Tree Widget
Version:
7.x-1.6
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
21 Nov 2011 at 13:25 UTC
Updated:
17 Aug 2012 at 16:11 UTC
Comments
Comment #1
okj579 commentedbump
Comment #2
bartk commentedTry changing #type to checkbox_tree and let me know if that works.
Comment #3
owntheweb commentedooO! I think this issue addresses close to what I need on a similar challenge. I'm making a custom form that generates lesson nodes (as part of a migration process - can't use standard form) and using your suggestion and some info on the first post I created this:
That gets me a nice expanded radiobutton list with the hierarchy of my vocabulary. Cool! (let me know if that helps answer this issue that's been dead for a while)
Bonus challenges:
Any thoughts on how I can make my form element a list of checkboxes for multiple values to be selected, make only the last leaf selectable, and make it show in one of those excellent expanding trees?
Thanks for the added assist in advance. :D
Chris
Comment #4
owntheweb commentedRegarding the "bonus challenges", this works!:
Comment #5
owntheweb commentedSorry, I accidentally changed the title earlier...
Comment #6
owntheweb commentedHmmmm. This doesn't validate though when I submit the form, highlighting my tree in red once I select an option (validates fine if empty):
Even if I add a custom validate function:
Any thoughts on what could be wrong? I'll keep digging...
EDIT:
In form.inc at line 1297-1298:
I can see why the error is happening. Here's what $v looks like:
Any thoughts on how to get around this oddness? :S
Thanks again,
Comment #7
owntheweb commentedHrmmm. I'm still stuck on this one. Any ideas? Thanks again,
Comment #8
mikran commentedHere is fixed version of bonus challenge, this should fix the error from comment #6.
Added rows explained:
This custom element_validate function is basically a workaround for the validation error. From the function comments: "This function sets the value of the tree widgets into a form that Drupal can understand, and also checks if the field is required and has been left empty.".
In addition to #element_validate #value is also needed and for the same reason I'd imagine. _term_reference_tree_widget_validate overwrites #value so it doesn't matter too much what the initial value is.
All the required element properties can be found from function term_reference_tree_field_widget_form(). Obviously these things could be improved to make it easier to use the widget as form API element.
Comment #9
owntheweb commentedAha! I knew I was missing something. I tried the '#element_validate' but didn't have the '#value' in place at the same time.
Thanks so much for your help! This resolved the error issue I was running into when submitting custom form.
:D :D :D :D :D
Comment #10.0
(not verified) commentedMinor edit