diff --git a/hierarchical_select.module b/hierarchical_select.module --- a/hierarchical_select.module +++ b/hierarchical_select.module @@ -399,6 +399,18 @@ * Hierarchical select form element type #process callback. */ function hierarchical_select_process($element, $edit, &$form_state, $form) { + // If we're in a callback where the ids have already been assigned to + // the elements, but we don't have information about them yet, then + // do nothing and return the element has is. + if (isset($_POST['hs_form_build_id']) && !isset($edit['hsid'])) { + return $element; + } + // If an id has been assigned and we can get to it, then use it and + // flag the whole process has a rebuild. + if (is_array($edit) && isset($edit['hsid'])) { + $element['#value']['hsid'] = $edit['hsid']; + $rebuild = TRUE; + } if (!is_array($element['#value']) || !isset($element['#value']['hsid'])) { // The HSID is stored in the session, to allow for multiple Hierarchical // Select form items on the same page of which at least one is added through @@ -462,6 +474,13 @@ ), ) ); + // If rebuiliding the form due to external AHAH events, such as + // CCK "Add more values" form rebuilding, then everything's already in place + // on the JS side (that's an AHAH submission after all), so, flag the widget + // as so. + if ($rebuild) { + $settings['HierarchicalSelect']['settings'][$hsid]['updatesEnabled'] = TRUE; + } _hierarchical_select_add_js_settings($settings, $form_state); // Basic config validation and diagnostics.