Hi all,
I wanted to send an httpRequest for each change in taxonomy multiselect fields (when editing cck nodes). I tried to add a ['#ahah'] param to all my taxonomy form entries, it works, but the WHOLE form is sent each time a select change. I expected to send only the form entry concerned.
Is this "normal" or is there another way to do this with ahah ? (D6, cck 6.x-2.0-rc6)
At the end, I found a solution without ahah, writing an external js file instead of ahah params in drupal $form, but I'm curious about ahah use.
My code :
// in my hook form_alter foreach ($form['taxonomy'] as $vid => $taxonomy_entry) { if ($taxonomy_entry['#type'] == 'select') { $form['taxonomy'][$vid]['#ahah'] = array( 'path' => 'eduforge/taxonomy_change/' .$vid, 'event' => 'change', 'wrapper' => 'eduforge_taxonomy_change_output', 'method' => 'replace', 'effect' => 'fade', ); } }
// in hook menu $items['eduforge/taxonomy_change/%'] = array ( 'page callback' => 'eduforge_taxonomy_change', 'page arguments' => array (2), 'type' => MENU_CALLBACK, /// ... );
function eduforge_taxonomy_change($vid) { // here, $_POST contains the whole form // some code drupal_json(array('status' => TRUE, 'data' => $returned_datas)); }
Thanks for advices
Daniel
On Tue, 16 Sep 2008, Daniel Caillibaud wrote:
I wanted to send an httpRequest for each change in taxonomy multiselect fields (when editing cck nodes). I tried to add a ['#ahah'] param to all my taxonomy form entries, it works, but the WHOLE form is sent each time a select change. I expected to send only the form entry concerned.
Is this "normal" or is there another way to do this with ahah ? (D6, cck 6.x-2.0-rc6)
I have no idea if it is normal, but if it isn't: What browsers have you tested with? IE6, for example, is known for this sort of thing (E.G. submitting all button values when a single button should have been sent per spec).
Luke
Le 15/09/08 à 19:14, Luke drupal@lists.tacticus.com a écrit :
I have no idea if it is normal, but if it isn't: What browsers have you tested with?
FF3 (on linux).
IE6, for example, is known for this sort of thing (E.G. submitting all button values when a single button should have been sent per spec).
Here, it's not a submit button but httpRequest from js. If the js call isn't supported by the used navigator, nothing should happen, but what is send is "decided" by the js code (as you can see in source html/js code). So I guess the pb is that the js object constructed by ahah js code (and sent) is the whole form where I expected only the select DOM object.