I've been trying to solve an AJAX problem and I found the solution after a full day of searching and trial-and-error.

I wrote down my issue on drupal.stackexchange.com with a link to the code, demo and solution. The solution was one(!) line of code. Unsetting the values in the 'input' array: unset($form_state['input']['my_element']);, where 'my_element' contains values that are passed after the callback.

I tried to fix this problem today by looking at the examples module a lot, but this unset() input fix isn't documented anywhere in the module. So while I still don't know what 'input' does and why it fixes this issue, I was wondering if anyone could shine some light on it and maybe an example in the ajax_example module could be nice? I would write one, but I'm not sure what makes my use case so different from others that it needs to unset the input array?

EDIT: more on this here:
http://drupal.stackexchange.com/a/27330/3124
and here:
http://drupal.org/node/1100170
Seems to be something that is somewhere between a bug and by design.

Comments

rfay’s picture

The only place *I* documented it is here: http://api.drupal.org/api/drupal/includes%21form.inc/function/drupal_bui...

It's pretty tweaky, I have to admit. But not hard to use at all. You just empty the item you're worried about.

Although I have used this, I don't seem to find an example of it. I would have thought it would have ended up in the multistep example, but it's so tweaky maybe I thought it was too obscure.

danny_joris’s picture

Thanks for your feedback, Randy. Appreciate it. Good to know it's probably not a common issue and glad there's a fix. I'm definitely going to give the drupal_build_form documentation another good read.

Thanks for all your work on the examples module and documentation. I find it extremely valuable.

danny_joris’s picture

Status: Active » Closed (fixed)
danny_joris’s picture

Issue summary: View changes

Updated the post with 2 more references where the issue has been addressed.