I'm trying to load additional content on a form when user selects a taxonomy term using a hierarchical select widget.

So far I found change-hierarchical-select event. I able to make needed AJAX call using a custom drupal behavior I implemented in a JS file included on a form. It requires a menu callback and looks a bit unwieldy, although works.

I'm looking for a way to simplify things using ajax form api. I've placed the following code in a hook_form_alter, but something doesn't work. Is '#ajax' attribute is supported by HS? How tasks similar to mine are supposed to be solved?

  $form['field_material']['#ajax'] = array('#callback' => 'westppu_custom_load_product',
                                           '#wrapper' => 'product_area',
                                           '#event' => 'change-hierarchical-select');

  $form['product_area'] = array(
    '#type' => 'markup',
    '#prefix' => '<div id="product_area">',
    '#markup' => '',
    '#suffix' => '</div>',
  );

Comments

wim leers’s picture

Assigned: Unassigned » wim leers
Status: Active » Fixed

You may want to do this using plain JS instead of #ajax. HS is too advanced/complex for #ajax.

akamaus’s picture

Status: Fixed » Active

Thanks for clarification. I've already implemented it using a custom menu handler. I just was looking for a more elegant way.

If to speak about the future... I understand what HS stands out in it complexity, but seems to me for 90% of use cases #ajax as a simple way to react on changing the selected entry would be enough.

kars-t’s picture

Assigned: wim leers » Unassigned
Status: Active » Fixed

Dear fellow Drupal enthusiasts,

this issue is now lasting for a very long time in the issue queue and was unfortunately never solved. As Drupal is a open source project everyone is helping on voluntary basis. So that this is was not solved is nothing personal and means no harm. But perhaps no one had time to deal with this issue, maybe it is too complex or did not describe the problem comprehensibly.

But this issue is not the only one. There are thousands of issues on Drupal.org that have never been worked on or could not be processed. This means that we are building a wave that is unmanageable and just a problem for the Drupal project as a whole. Please help us keep the issue queue smaller and more manageable.

Please read again, "Making an issue report" and see if you can improve the issue. Test the problem with the current Core and modules. Maybe the problem doesn't exist anymore, is a duplicate or has even been solved within this issue but never closed.

Help can also be found for it on IRC and in the user groups.

In order to remove this issue, I have set this issue to "fixed"

If there is new information, please re-open the issue.

Status: Fixed » Closed (fixed)

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