I have created a module and a form. The form is presented properly, including the data from the records it manages (using the xxx_load function and URL wildcards). The form validate function gets called properly. But my submit function is not called. I do have a submit element in the form, but in the HTML rendered page it shows up as a submit-type button with the name 'op'. My suspicion is that this is the reason my submit function is not called. Furthermore, when I press the submit button, the same form is shown again (with changed data), even if I add a 'redirect' element to my form. There are no error messages, not on screen, nor in the reports.
Using D6.9
What have I already ruled out:
- Nowhere in my own modules or in the template.php do I execute a hook_form_alter() on this form.
- The function names are proper and the parameter lists are as is described in the FAPI 6.x documentation
I have searched the web extensively, but cannot resolve my issue. Can anyone point me in the right direction?
Thanx.
Comments
Probably something wrong with
Probably something wrong with your code.
Contact me to contract me for D7 -> D10/11 migrations.
Wrong with my code - obviously
OK, some more debug background:
- The entire _validate() function get's executed and returns properly
- The _submit() function not called at all. Even a print statement as the very first statement in the function, does not get executed.
Can you post your submit
Can you post your submit function or part of it? The redirection is surely happening because the submit is not being called. If the submit function is no defined or coded then it will just refresh the page and input the default values (could explain the form values changing?).
Code snippets
Here are the code snippets:
Try modifying the name of the
Try modifying the name of the submit function to MODULE_NAME_SUBMIT or in your case onder_een_dak_submit(). Right now you have some additional information between the hook and the module itself. I think this may be why you are not seeing it execute.
This is not a node form,
This is not a node form, hook_submit is totally inappropriate.
What you have there looks
What you have there looks fine. Why don't you put the rest of your form definition up.
Contact me to contract me for D7 -> D10/11 migrations.
Form definition function
Hi guys, here's the whole function:
SOLVED
OK, I have solved the issue (but in unearthed another one). Here's the what and the how.
It turns out that my validate function sets and error (with form_set_error() ). The only thing is, the error was not showing at the top of my form.
The way I found out: I installed xdebug and traced the execution logic. There I found out that form_set_error() was called. From there it was easy to find which form_set_error() was actually called and I could update the program logic in the validate function.
Thanks to all for chipping in.
Glad to hear you found
Glad to hear you found it.
Sounds like $messages is not being outputted in your theme's page.tpl.php. Either that or you are overwriting them somehow in your theme's template.php.
Contact me to contract me for D7 -> D10/11 migrations.
Try using the submit hook for
Try using the submit hook for your form. Doing so will cause the code within that function to be executed.
http://drupal.org/node/58689
Tried the submit property
I tried the submit property in the form (although the 6 version of course). No luck.
Please post your code. We
Please post your code. We cannot help you otherwise.
Hi phkemper, I've got exactly
Hi phkemper,
I've got exactly the same problem as you had. I installed xdebug and got it running with eclipse. But I don't know how to use it. By pressing F11 Firefox opens my project and Eclipse opens the PHP Debug perspective.
Can you tell me where you saw which functions get called? And where I should set a breakpoint (at the validate function or somewhere else)? I'm a little lost as you can see ;)
Thanks for your help!
Greetz
haggins
Form Submit and Validate Handlers not getting called.
I have the same problem, except neither validate or submit get called when I use the form element submit like below. Am I doing something stupid?
I have defined a page called testme in hook_menu below, which returns my form. Also..I'm using "Drupal for Firebug" module so that's what these firep()'s are
Same problem<?phpfunction
Same problem