By Predated on
Issue solved, please see the 3rd comment below for an example of making it all work.
Thanks to Wim Leers and Kat Bailey, and alot of sites that were talking about AHAH. I also thank my brain for staying in my head while I beat it into submission around the whole concept of AHAH in Drupal 6.
Comments
Your form must react to $form_state
You need to first of all make sure that your form will react to $form_state, i.e. that it will always get built according to what's in $form_state. What this means in your particular case is that in your form function when you are building your rooms dropdown, you first check to see if you have a selected location id and populate it based on that. So you'll call a function to look up the rooms for the selected location and that's where your SQL query will go, NOT in your ahah callback. That way, when your ahah callback renders the form, it'll do so with an actual value for lid, which your rooms dropdown will then react to. The Quick Tabs module does this for its View displays dropdown so you could have a look there to get a better understanding of how it works.
Thanks Kat :) I actually
Thanks Kat :)
I actually found your blog post about the updates you made in Quicktabs where you discussed all that, I just hadn't posted back about it. I'm pretty sure I have it hammered out at this point, but another project I was working on got it's priority bumped up, and I haven't had a chance to get back to it.
I think I was making AHAH a lot more complicated than it is, and I was getting really frustrated with it. Going back to it after not looking at it for a couple of days made quite a difference. I'll have to post back here when I have it working.
Got it working
I got it working some time ago, and just never got around to posting it back here. But in the interest of saving someone some frustration down the road, there is an example of the bare minimum you'd need down below. Please note that the example code hasn't been tested.
You'll want to have a look at:
Doing AHAH in D6 the right way
Wim Leers' blog post about ahah_helper
Kat Bailey's blog post on the duality of forms
First of all you'll need a menu callback:
And of course, you'll need a form:
And you'll need to get the options for your select field somehow as well - this function would pull it from a database:
The magic all happens with your AHAH callback function, in this case, simple_ahah_render:
I am still a little bit confused
I got it to work,
forget about my last message
thanks!
I think my brain did explode, but thanks a ton for writing this up!! Finally I'm not getting "Drupal detected an illegal action" errors.
Thanks for posting this, it's
Thanks for posting this, it's exactly what I was looking for.
By building around your code, I've been able to create the form I was expecting; yet when I submit it it won't use the $form['#redirect'] attribute I've tried setting in pretty much every part of the code; it keeps going back to the form instead. Doesn't make sense since, theoretically, the callback function only reloads the code delimited by the wrapper, but obviously I'm getting something wrong here.
Any ideas on getting around this?
Thanks
Hi and thanks a lot for this howto !
I was looking for a solution to populate a list for an autocomplete textfield from a select field and your topic gave me a first step to do that.
I give some precision on http://drupal.org/node/812956 if you'd like to have a look. If you could, i would be very interested by a feedback.
But now, i'll go to check what ahah helper module do, maybe it could be useful ! (But i saw that the usage statistic curve is a little bit special... do you know why there is a very big increase and decrease in only few monthes ?)
Tim Baret
I tried to apply your code to
I tried to apply your code to my module but as with another example im getting a popup with 'an error occured'
here is the whole code
in matches.module
matches.list.admin.inc
im really really frustrated about that issue .. i really cannot get any example to work and it looks like ahah_helper is not made for what i wanna do ...
If someone could enlight me it would be REALLY appreciated ...
why do you think ahah_helper
why do you think ahah_helper can't do what you want ?
I didn't read all your code, what do you want to do actually ?
Tim Baret
I want to populate a select
I want to populate a select list from another one, i found a few nodes talking about that but all the examples (including this post's one) i tried, failled and i don't know where is located the probleme. I'd really appreciate that someone give a look to my code and help me figure out what's wrong ... :/
up on this, still didn't fix
up on this, still didn't fix the issue and i really need to get this working :/
Thank you
Thank you for this
Thanks, I was looking for
Thanks,
I was looking for that!
If hierarchical select is enabled the following error appears:
I almost died the last days
I almost died the last days on getting AHAH to work, I really recommend everyone that wants to use AHAH to check out the AHAH helper module! It enlightened me and has a nice demo added (look into the code!!!).
Yes I appreciate with this.
AHAH helper module is really great for ahah, using this module we no need to implement all ahah framework, just need to register some helper functions, which minimize lots of code and complexity too.
Cheers,
Rajan
Hi, would you mind giving me
Hi,
would you mind giving me an example of how you implented it ? would be really appreciated :) thanks
here is an simple example
I have implemented an example http://bit.ly/aTLfjV, which allows to modify/set options of select box one depending upon selected option another select box.
Cheers,
Rajan
Thanks you
Hi Rajan,
Thank you for your tutorial. I have implemented your code in my application, While selecting the first drop down value "Option 2" its remain "Options 1". Could you please help me on this.
Also, I have created the form using the content type. I am trying to implement this in hook_form_alter instead of the hook_form. Could you please help me on this.
Yes I appreciate with this.
AHAH helper module is really great for ahah, using this module we no need to implement all ahah framework, just need to register some helper functions, which minimize lots of code and complexity too.
Cheers,
Rajan
subscribing. Tons of great
subscribing. Tons of great info in this thread.