In a module, I am using drupal_get_form() to load a form from a .inc file. That works fine. But when it is submitted, the submission handler can't be found; it's also in the .inc file. How do I get around this?
Nancy
Hi Nancy, Ok, dumb question probably, but why wouldn't your submit function be inthe .module file? Isn't that where Drupal would look for it?
Regards,
Cindy Dykstra WebMaker Inc. http://webmakerinc.com 719-276-0908 toll-free: 866-376-0908
Facebook http://www.facebook.com/webmakerinc - LinkedIn http://www.linkedin.com/in/webmakerinc
On 1/31/2013 10:27 AM, Ms. Nancy Wichmann wrote:
In a module, I am using drupal_get_form() to load a form from a .inc file. That works fine. But when it is submitted, the submission handler can't be found; it's also in the .inc file. How do I get around this? /*Nancy*/
On Thu, Jan 31, 2013 at 12:50 PM, Cindy Dykstra, WebMaker Inc. wrote:
Hi Nancy, Ok, dumb question probably, but why wouldn't your submit function be in the .module file? Isn't that where Drupal would look for it?
No, it doesn't have to be. The verification and submit functions should be with the form.
-- Earnie -- https://sites.google.com/site/earnieboyd
Oh, yes that makes sense that they should all be in the same file. I'm just dipping my toes into development, so thank you for answering.
Cindy Dykstra
On 1/31/2013 11:37 AM, Earnie Boyd wrote:
On Thu, Jan 31, 2013 at 12:50 PM, Cindy Dykstra, WebMaker Inc. wrote:
Hi Nancy, Ok, dumb question probably, but why wouldn't your submit function be in the .module file? Isn't that where Drupal would look for it?
No, it doesn't have to be. The verification and submit functions should be with the form.
-- Earnie -- https://sites.google.com/site/earnieboyd
On Thu, Jan 31, 2013 at 12:27 PM, Ms. Nancy Wichmann wrote:
In a module, I am using drupal_get_form() to load a form from a .inc file. That works fine. But when it is submitted, the submission handler can't be found; it's also in the .inc file. How do I get around this?
Uh, I thought that was how it should be done. Can you give us a mock up of your form and menu item?
In hook_node_view(), I have: require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'mymodule') . '/mymodule.pages.inc'; $form = drupal_get_form('mymodule_tab_form', $node, $mymodule->wid, $states, $current); $form['#weight'] = 99;
$node->content['mymodule'] = $form;
I'm guessing that this technically makes the form part of the main module, while the submission handler is still in the .inc file.
BTW, I even tried adding the .inc file name to the .info file. No help.
Nancy
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
From: Earnie Boyd earnie@users.sourceforge.net To: support@drupal.org Sent: Thursday, January 31, 2013 1:35 PM Subject: Re: [support] Form submission problem
On Thu, Jan 31, 2013 at 12:27 PM, Ms. Nancy Wichmann wrote:
In a module, I am using drupal_get_form() to load a form from a .inc file. That works fine. But when it is submitted, the submission handler can't be found; it's also in the .inc file. How do I get around this?
Uh, I thought that was how it should be done. Can you give us a mock up of your form and menu item?
-- Earnie
-- https://sites.google.com/site/earnieboyd
[ Drupal support list | http://lists.drupal.org/ ]
Nancy,
I'm starting to believe that the problem is that the #submit handler is not wired correctly to this form. If require_once failed it would throw a hard error and no form would render. This means that the function that the form handler thinks is the submit handler is not the same as the one you think it is. I think the include is not the problem or the form wouldn't render.
Is it possible that something is overriding the submit handler. #submit attributes on the form in drupal 7 might do that.
Are you using 6 or 7?
$form_state['rebuild'] sets in the validation handler might cause this. $form_state['storage'] sets in the validation handler in D6 might also cause this.
Dave
________________________________ From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Ms. Nancy Wichmann Sent: Thursday, January 31, 2013 4:49 PM To: support@drupal.org Subject: Re: [support] Form submission problem
In hook_node_view(), I have: require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'mymodule') . '/mymodule.pages.inc'; $form = drupal_get_form('mymodule_tab_form', $node, $mymodule->wid, $states, $current); $form['#weight'] = 99;
$node->content['mymodule'] = $form;
I'm guessing that this technically makes the form part of the main module, while the submission handler is still in the .inc file.
BTW, I even tried adding the .inc file name to the .info file. No help.
Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
________________________________ From: Earnie Boyd earnie@users.sourceforge.net To: support@drupal.org Sent: Thursday, January 31, 2013 1:35 PM Subject: Re: [support] Form submission problem
On Thu, Jan 31, 2013 at 12:27 PM, Ms. Nancy Wichmann wrote:
In a module, I am using drupal_get_form() to load a form from a .inc file. That works fine. But when it is submitted, the submission handler can't be found; it's also in the .inc file. How do I get around this?
Uh, I thought that was how it should be done. Can you give us a mock up of your form and menu item?
-- Earnie -- https://sites.google.com/site/earnieboyd -- [ Drupal support list | http://lists.drupal.org/ ]
http://api.drupal.org/api/drupal/includes%21form.inc/function/form_load_incl... help, although I also suspect something is wrong with setting the submit function. On Feb 1, 2013 2:25 AM, "Metzler, David" metzlerd@evergreen.edu wrote:
****Nancy****, ****
I’m starting to believe that the problem is that the #submit handler is not wired correctly to this form. If require_once failed it would throw a hard error and no form would render. This means that the function that the form handler thinks is the submit handler is not the same as the one you think it is. I think the include is not the problem or the form wouldn’t render. ****
Is it possible that something is overriding the submit handler. #submit attributes on the form in drupal 7 might do that. ****
Are you using 6 or 7? ****
$form_state[‘rebuild’] sets in the validation handler might cause this. ** **
$form_state[‘storage’] sets in the validation handler in D6 might also cause this. ****
Dave****
*From:* support-bounces@drupal.org [mailto:support-bounces@drupal.org] *On Behalf Of ***Ms. Nancy Wichmann** *Sent:* Thursday, January 31, 2013 4:49 PM *To:* **support@drupal.org** *Subject:* Re: [support] Form submission problem****
In hook_node_view(), I have:****
require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'mymodule') . '/mymodule.pages.inc'; $form = drupal_get_form('mymodule_tab_form', $node, $mymodule->wid, $states, $current); $form['#weight'] = 99;
$node->content['mymodule'] = $form;
I'm guessing that this technically makes the form part of the main module, while the submission handler is still in the .inc file.****
BTW, I even tried adding the .inc file name to the .info file. No help.
*****Nancy***** ****
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.****
*From:* Earnie Boyd earnie@users.sourceforge.net *To:* **support@drupal.org** *Sent:* Thursday, January 31, 2013 1:35 PM *Subject:* Re: [support] Form submission problem****
On Thu, Jan 31, 2013 at 12:27 PM, **Ms. Nancy Wichmann** wrote:
In a module, I am using drupal_get_form() to load a form from a .inc
file.
That works fine. But when it is submitted, the submission handler can't
be
found; it's also in the .inc file. How do I get around this?
Uh, I thought that was how it should be done. Can you give us a mock up of your form and menu item?
-- Earnie
-- https://sites.google.com/site/earnieboyd
[ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
Thanks, Hans. That was a new one to me, as a lot of D7 stuff is. But it didn't solve the problem. Oh well.
Nancy
From: Hans Langouche
I’m starting to believe that the problem is that the #submit handler is not wired correctly to this form. If require_once failed it would throw a hard error and no form would render. This means that the function that the form handler thinks is the submit handler is not the same as the one you think it is. I think the include is not the problem or the form wouldn’t render.
Is it possible that something is overriding the submit handler. #submit attributes on the form in drupal 7 might do that. Are you using 6 or 7? $form_state[‘rebuild’] sets in the validation handler might cause this. $form_state[‘storage’] sets in the validation handler in D6 might also cause this. Dave
From:support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Ms. Nancy Wichmann Sent: Thursday, January 31, 2013 4:49 PM To: support@drupal.org Subject: Re: [support] Form submission problem In hook_node_view(), I have: require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'mymodule') . '/mymodule.pages.inc'; $form = drupal_get_form('mymodule_tab_form', $node, $mymodule->wid, $states, $current); $form['#weight'] = 99;
$node->content['mymodule'] = $form;
I'm guessing that this technically makes the form part of the main module, while the submission handler is still in the .inc file. BTW, I even tried adding the .inc file name to the .info file. No help.
Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
From:Earnie Boyd earnie@users.sourceforge.net To: support@drupal.org Sent: Thursday, January 31, 2013 1:35 PM Subject: Re: [support] Form submission problem
On Thu, Jan 31, 2013 at 12:27 PM, Ms. Nancy Wichmann wrote:
In a module, I am using drupal_get_form() to load a form from a .inc file. That works fine. But when it is submitted, the submission handler can't be found; it's also in the .inc file. How do I get around this?
Uh, I thought that was how it should be done. Can you give us a mock up of your form and menu item?
-- Earnie
-- https://sites.google.com/site/earnieboyd
[ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
Nancy, can you put an error_log statement or some such in the file and another in the handler to verify whether they are (not) being loaded?
On Feb 1, 2013, at 9:23 AM, "Ms. Nancy Wichmann" nan_wich@bellsouth.net wrote:
Thanks, Hans. That was a new one to me, as a lot of D7 stuff is. But it didn't solve the problem. Oh well.
Nancy
From: Hans Langouche I’m starting to believe that the problem is that the #submit handler is not wired correctly to this form. If require_once failed it would throw a hard error and no form would render. This means that the function that the form handler thinks is the submit handler is not the same as the one you think it is. I think the include is not the problem or the form wouldn’t render.
Is it possible that something is overriding the submit handler. #submit attributes on the form in drupal 7 might do that.
Are you using 6 or 7?
$form_state[‘rebuild’] sets in the validation handler might cause this. $form_state[‘storage’] sets in the validation handler in D6 might also cause this.
Dave
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Ms. Nancy Wichmann Sent: Thursday, January 31, 2013 4:49 PM To: support@drupal.org Subject: Re: [support] Form submission problem
In hook_node_view(), I have: require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'mymodule') . '/mymodule.pages.inc'; $form = drupal_get_form('mymodule_tab_form', $node, $mymodule->wid, $states, $current); $form['#weight'] = 99;
$node->content['mymodule'] = $form;
I'm guessing that this technically makes the form part of the main module, while the submission handler is still in the .inc file.
BTW, I even tried adding the .inc file name to the .info file. No help.
Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
From: Earnie Boyd earnie@users.sourceforge.net To: support@drupal.org Sent: Thursday, January 31, 2013 1:35 PM Subject: Re: [support] Form submission problem
On Thu, Jan 31, 2013 at 12:27 PM, Ms. Nancy Wichmann wrote:
In a module, I am using drupal_get_form() to load a form from a .inc file. That works fine. But when it is submitted, the submission handler can't be found; it's also in the .inc file. How do I get around this?
Uh, I thought that was how it should be done. Can you give us a mock up of your form and menu item?
-- Earnie
-- https://sites.google.com/site/earnieboyd
[ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
If you're willing to post your form and form_submit handler code, I'd be willing to take a look at it (or contact my via drupal contact form).
Again, if what you say is true (the form is rendering but the submit handler is not executing and they are in the same file). I think we can safely assume your include file is in fact being loaded. Any tweaks to that are futile.
By the way, if the hook_nood_view is in the same module as the form's include file, using
require_once 'mymodule.pages.inc' ;
Is quite adequate. Using all the drupal get path and stuff is only necessary if you are loading code from a different module.
Dave
________________________________ From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Ms. Nancy Wichmann Sent: Friday, February 01, 2013 6:24 AM To: support@drupal.org Subject: Re: [support] Form submission problem
Thanks, Hans. That was a new one to me, as a lot of D7 stuff is. But it didn't solve the problem. Oh well.
Nancy
________________________________ From: Hans Langouche I'm starting to believe that the problem is that the #submit handler is not wired correctly to this form. If require_once failed it would throw a hard error and no form would render. This means that the function that the form handler thinks is the submit handler is not the same as the one you think it is. I think the include is not the problem or the form wouldn't render.
Is it possible that something is overriding the submit handler. #submit attributes on the form in drupal 7 might do that.
Are you using 6 or 7?
$form_state['rebuild'] sets in the validation handler might cause this. $form_state['storage'] sets in the validation handler in D6 might also cause this.
Dave
________________________________ From: support-bounces@drupal.orgmailto:support-bounces@drupal.org [mailto:support-bounces@drupal.orgmailto:support-bounces@drupal.org] On Behalf Of Ms. Nancy Wichmann Sent: Thursday, January 31, 2013 4:49 PM To: support@drupal.orgmailto:support@drupal.org Subject: Re: [support] Form submission problem
In hook_node_view(), I have: require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'mymodule') . '/mymodule.pages.inc'; $form = drupal_get_form('mymodule_tab_form', $node, $mymodule->wid, $states, $current); $form['#weight'] = 99;
$node->content['mymodule'] = $form; I'm guessing that this technically makes the form part of the main module, while the submission handler is still in the .inc file.
BTW, I even tried adding the .inc file name to the .info file. No help.
Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
________________________________ From: Earnie Boyd <earnie@users.sourceforge.netmailto:earnie@users.sourceforge.net> To: support@drupal.orgmailto:support@drupal.org Sent: Thursday, January 31, 2013 1:35 PM Subject: Re: [support] Form submission problem
On Thu, Jan 31, 2013 at 12:27 PM, Ms. Nancy Wichmann wrote:
In a module, I am using drupal_get_form() to load a form from a .inc file. That works fine. But when it is submitted, the submission handler can't be found; it's also in the .inc file. How do I get around this?
Uh, I thought that was how it should be done. Can you give us a mock up of your form and menu item?
-- Earnie -- https://sites.google.com/site/earnieboyd -- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
On Thu, Jan 31, 2013 at 7:48 PM, Ms. Nancy Wichmann nan_wich@bellsouth.net wrote:
In hook_node_view(), I have: require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'mymodule') . '/mymodule.pages.inc';
You need to identify this file as required for the form. Usually done in hook_menu but in this case you cannot add it since the 'file' attribute for menu items array isn't an array but a single file. About the only thing I know to do without much more research is to move this require_once into the global space making it part of mymodule.module.
$form = drupal_get_form('mymodule_tab_form', $node, $mymodule->wid, $states, $current); $form['#weight'] = 99;
$node->content['mymodule'] = $form; I'm guessing that this technically makes the form part of the main module, while the submission handler is still in the .inc file.
BTW, I even tried adding the .inc file name to the .info file. No help.
AIUI, this only helps if you have a class defined.
Good luck,