I have several HS fields in a content type. When trying to create a new node of this content type and if there's a validation error because a required field is not filled and then tried to update a HS field, all HS fields are changed at once.

The reason I found is that in hierarchical_select.js, response.output is returned null in below code part and thus change all HS fields in the document.

      // Replace the old HTML with the (relevant part of) retrieved HTML.
      $('#hierarchical-select-'+ hsid +'-wrapper', Drupal.HierarchicalSelect.context)
      .html($('.hierarchical-select-wrapper > *', $(response.output))); 

On the server side, this happens because the following condition becomes false after the form resubmission and server cache is not updated after new HS fields are created.

function hierarchical_select_after_build($form, $form_values) {
  $names = _hierarchical_select_store_name(NULL, NULL, TRUE);

  $post_hs_form_build_id = _hierarchical_select_get_hs_form_build_id();
  if (!isset($post_hs_form_build_id) && count($names)) {
    $parameters = (isset($form['#parameters'])) ? $form['#parameters'] : array();

-Laknath

Comments

wim leers’s picture

Status: Active » Closed (fixed)