Timeline for hook_form_alter isn't being called when node fails validation
Current License: CC BY-SA 3.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 15, 2012 at 17:12 | vote | accept | Arosboro | ||
Apr 15, 2012 at 17:12 | comment | added | Arosboro | After adding an empty wrapper to the finding field for the textarea (it was in the alter hook before), the ajax callback started working. At least I think this change was what fixed it. Thanks for your help, I've accepted your answer. | |
Apr 15, 2012 at 16:48 | comment | added | Arosboro | I'm writing a module called text_field_reference that autocompletes to the value of a field in the recommendation content type I've created. The recommendations match up to a finding select field that has integer point values (0, 1, 2, etc). If the user changes the select field, I use an ajax call to display a textarea that autocompletes to a recommendation. Its blur event replaces the field_text_reference field with a key representing the node that was referenced. I'll be the first to admit it's kind of hackish. The ajax callback to replace the reference field is intermittently working. | |
Apr 15, 2012 at 16:28 | comment | added | Alex Weber | Could you please elaborate on exactly what you are trying to do with adding the extra field? It doesn't appear in your validation error because #access was set to false, you could try checking for form_get_errors() in your after build and setting #access to true if there are any | |
Apr 15, 2012 at 15:40 | comment | added | Arosboro |
If I add the field in the form_alter, it doesn't appear on the validation error page. I decided to create the field in my after_build callback, but the #ajax callback is not being fired. Autocomplete works fine. When dealing with form_alter I found that I had to add the wrapper with #printed => TRUE to the root of the array, and then copy the field to the element I wanted it to display under. I think the callback worked then because the field had already been recognized during rendering. Do I need to call field_default_form or some other function to get ajax callbacks to work?
|
|
Apr 15, 2012 at 4:20 | comment | added | Alex Weber | Technically yes you can do anything with the form. That said, you might be better off adding the field in your form alter with #access FALSE and then setting it to TRUE in your after build if necessary. | |
Apr 15, 2012 at 4:18 | comment | added | Arosboro | is it possible to add elements to the form? I'm adding a textarea when a value is set in a particular field. | |
Apr 15, 2012 at 4:08 | history | answered | Alex Weber | CC BY-SA 3.0 |