Posted by Tengu on June 9, 2010 at 3:51pm
Hello masters :)
I hope someone from you can help me a little bit.
I have a multistep form with AHAH enhanced elements (with AHAH Helper). All runs fine.
Now I have to insert a new form element (a select) with AHAH. This is no problem, I render the new form element with drupal_render in the form definition directly in the output of the wrapper-div and build the form element before.
This new element have AHAH functionality too and THIS doesn't function. There is no reaction when I click in the select.
Can you help me please with a hint? Forget I something?
Thank you
Tengu
Comments
Hi Tengu, "Hierarchal AHAH
Hi Tengu,
"Hierarchal AHAH elements" (AHAH elements creating other AHAH elements) are tricky business. I've done this before, but not recently so I can't give you any suggestions off the top of my head. I remember I had issues with missing entries in Drupal.settings JavaScript variables for AHAH elements that were also created through AHAH.
Have you seen the Conditional Fields module? It's a really handy tool for showing/hiding CCK fields based on the values of other fields. It might provide the functionality you're looking for.
---
Yuriy Babenko
http://yuriybabenko.com
My Drupal tutorials: http://yuriybabenko.com/blog/tag/tutorials
In my AHAH callback function,
In my AHAH callback function, this works for me:
<?php// main bulk of callback function not shown
$output = drupal_render($changed_elements);
// this next section does the magic
$javascript = drupal_add_js(NULL, NULL);
if(isset($javascript['setting']))
{
$output .= '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])) .');</script>';
}
print drupal_to_js(array('data' => $output, 'status' => true));
?>
Full-time freelancer, always looking for work.
jaypan.com (my portfolio)
Thanks!
This has save me a bunch of headaches, been trying to solve this for the longest time.
JPL
Thanks you all :)
Unfortunately the Conditional Fields module is not an option for me. The thingy with the drupal settings I remberered, yes. But I didn't find it in the net anymore :-(
I solved it now with hook_form_FORM_ID_alter. I define the new AHAH enhanced form element in this hook directly in the wrapper from the previous AHAH wrapper. A manual rendering isn't necessary then. So it's all fine. Surely not the smartest solution but it functions :)
Thanks :)