I am trying to implement a Hierarchical Select based module that extends it behind the taxonomy selection, into giving also the nodes and some data processed through the Feeds API. Basically, there is a process which allows the user to go from selecting an hierarchical Taxonomy, then the nodes related to the taxonomy and finally a set of years available in the DB for the selected nid.
I am pretty new to Drupal's module development and I am having problems in catching and processing the values that are being sent on each POST.
The first problem I have is with selecting the appropriate hook to act on the POST data. Here, I have opted for the hook_hierarchical_select_valid_item(). I know it is the wrong one as it runs for each item on the list,, but I could not find a hook to act on each POST
function hs_indicator_hierarchical_select_valid_item($item, $params) {
$hierarchy = hs_indicator_hierarchy();
hs_indicator_post_selection($form_state['values']['hs_indicator']);
}
return isset($hierarchy[$item]['label']);
}
Then, I put hs_indicator_post_selection(), which, for testing purposes as this:
function hs_indicator_post_selection() {
$value = $form_state['values']['hs_indicator'];
$state = array (
'text' => "Some text",
'status' => 0,
);
// drupal_add_js(array('state' => $state), 'setting'); // alternative which I also tried
_hierarchical_select_add_js_settings(array('state' => $state), $form_state); // a hierarchical_select implementation for drupal_add_js
}
The $form_state['value']['hs_indicator'] seems to have all that I need (it is a concatenation of the different elements selected). However, drupal_add_js or _hierarchical_select_add_js_settings are not adding the new arrays on additional POSTs, only on the first, when the page is generated. Therefore, the variable is not getting updated.
The reason why I need this variables in Drupal.settings is because I need to get the information (either the step of the process or the final selection, which should retrieve the data needed to generate an OpenLayers layer) in an associated javascript . Here, I have:
Drupal.behaviors.SelectIndicator = function (){
// code here to show something or generate layers, etc.
}
Finally, I have the problem with sending a large amount of data in JSON format. Will it be possible that, within hs_indicator_post_selection() some data is put in JSON format and sent to the js function?
Thanks for any help and sorry for the long list, but I just got pretty confused in the last hours.
1 year 18 weeks ago