is there a way to enable taxiselect in a user profile with the "User terms" module?

Comments

alan d.’s picture

Category: feature » support

Not out of the box, but it would be possible I think. It would be a bit of a custom solution to integrate these, so I will not integrate via the module but can help out with some custom code if anyone wants to give it a go.

Note that the two branches are significantly different. It is easier to do via 6.x-1 (single textfield + autocomplete) but recommend 6.x-2 albeit more difficult (custom FAPI element + multiple AHAH support).

The AHAH callback (6.x-2 branch) will work out of the box, as no special includes are required and this uses a generic approach as the #array_parents parameter is used to create the URL.

Step 1) I would first look at hook_user $ops form & register to insert the widget (FAPI element to be exact).

Step 2) Then use hook_user $op submit to "fix" the $form_state values ($edit array in this hook). By fixing, I mean that it contains non-numeric values that get passed on. These probably need to be removed or user terms may complain about trying to insert strings & arrays into {user_terms}. Drupal core crashes if you do not. This isn't a bug, just the age old error, GIGO (Garbage in, garbage out)! A validate function could also be used to clean up.

A typical submit for multiple values contains something like:

array (
1 => 1
6 => 6
'add' => array(
'submit' => 'some string'
)
)

where it should just be:

array (
1 => 1
6 => 6
)

Step 3) Let User terms to finish off, which would save the data via hook_user $op insert / update.

Using this approach, the {system} weight of the module that does this must be GREATER than the weight of the user terms module. A hook_form_alter may be called after hook_user $op form / register, so this would bypass the need to worry about this.

Free tagging support and maybe CCK have to be the next issues that I tackle with this module, and some of my other modules require some tlc

alan d.’s picture

Status: Active » Closed (fixed)

Ya gotta hate technical replies. Closing to clean up the queue.