Using drupal_execute

View: New views
8 Messages — Rating Filter:   Alert me  

Using drupal_execute

by Jeff Greenberg-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I can't get this form to programatically display (not part of any
callback) and wait for a submission.


I call it, and it fires the function that creates the form array, but I
never see the form unless I put 'exit' after it.


When using drupal_execute, is the 'values' array of $form_state
required, with each field named?  My $form_state array is empty. I
didn't think I needed the enumerated 'values' array because I assumed
(yes, I know...) that the #default entries in the form elements
accomplish what I need.


Re: Using drupal_execute

by Ezra B. Gildesgame-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm not sure what your end goal is here (nor how a form would display
if not as the result of a callback), but it sounds like you may want
to use drupal_get_form instead. drupal_execute is for submitting form
values programatically, not displaying the form.

See:

http://api.drupal.org/api/function/drupal_get_form/6
http://api.drupal.org/api/function/drupal_execute/6

Best,
Ezra

--
Ezra Barnett Gildesgame | http://growingventuresolutions.com | http://ezra-g.com

On Thu, Oct 22, 2009 at 1:32 PM, Jeff Greenberg <jeff@...> wrote:

> I can't get this form to programatically display (not part of any callback)
> and wait for a submission.
>
>
> I call it, and it fires the function that creates the form array, but I
> never see the form unless I put 'exit' after it.
>
>
> When using drupal_execute, is the 'values' array of $form_state required,
> with each field named?  My $form_state array is empty. I didn't think I
> needed the enumerated 'values' array because I assumed (yes, I know...) that
> the #default entries in the form elements accomplish what I need.
>
>

Re: Using drupal_execute

by Jeff Greenberg-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ezra B. Gildesgame wrote:

> I'm not sure what your end goal is here (nor how a form would display
> if not as the result of a callback), but it sounds like you may want
> to use drupal_get_form instead. drupal_execute is for submitting form
> values programatically, not displaying the form.
>
> See:
>
> http://api.drupal.org/api/function/drupal_get_form/6
> http://api.drupal.org/api/function/drupal_execute/6
>
> Best,
> Ezra
>
>  
I tried drupal_get_form first, with the same result, or lack thereof.
Here's what I'm doing. I have a form that displays as a result of a
callback from an admin menu entry. The form uploads and processes a csv
file. In the submit function of that form, if the validate function
reports that it's unclear from the csv layout which columns are to be
used, I need another form presented from which the user selects the
appropriate columns. So, at that point I want to display another form,
so I called drupal_get_form, which does create the form, but never shows
it. Perhaps it's because I'm still in the submit function of the prior
form...but I was thinking that I need to do the second form before
completely returning from the callback that launched the first one.

Re: Using drupal_execute

by Jeff Greenberg-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I guess the question, then, is if I am processing a form:  
callback->form()->validate()->submit()   how do I handle the need to
have the submission result in another form being displayed?

Re: Using drupal_execute

by Greg Knaddison - GVS :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Oct 22, 2009 at 1:31 PM, Jeff Greenberg <jeff@...> wrote:
> I guess the question, then, is if I am processing a form:
>  callback->form()->validate()->submit()   how do I handle the need to have
> the submission result in another form being displayed?

Either multistep forms, or more likely you set your form destination
to the page where the next form is.

Greg

--
Greg Knaddison | 303-800-5623 | http://growingventuresolutions.com
Cracking Drupal - Learn to protect your Drupal site from hackers
Now available from Wiley http://crackingdrupal.com

Re: Using drupal_execute

by Jeff Greenberg-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

So, the first form is the result of hooking menu() and adding an entry
with a page callback of drupal_get_form.  The second form has its
drupal_get_form in the first form's submit routine (which apparently
works fine to create the form, but not to show it).


The docs say that a redirect should really be done by naming the
location in the form's submit callback...but the first form's submit
callback function is where I'm already trying to process the second
form. If the second drupal_get_form needs to be a page callback instead
of sitting in the function where it is, where do I define that callback?
It's not a separate menu choice, so it wouldn't be in menu()...?


Greg Knaddison wrote:

> Either multistep forms, or more likely you set your form destination
> to the page where the next form is.
>  

Re: Using drupal_execute

by Greg Knaddison :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hook_menu elements don't have to be visible as menu choices.

On http://api.drupal.org/api/function/hook_menu see type of MENU_CALLBACK

Regards,
Greg

On Thu, Oct 22, 2009 at 1:56 PM, Jeff Greenberg <jeff@...> wrote:

> So, the first form is the result of hooking menu() and adding an entry with
> a page callback of drupal_get_form.  The second form has its drupal_get_form
> in the first form's submit routine (which apparently works fine to create
> the form, but not to show it).
>
>
> The docs say that a redirect should really be done by naming the location in
> the form's submit callback...but the first form's submit callback function
> is where I'm already trying to process the second form. If the second
> drupal_get_form needs to be a page callback instead of sitting in the
> function where it is, where do I define that callback? It's not a separate
> menu choice, so it wouldn't be in menu()...?
>
>
> Greg Knaddison wrote:
>
>> Either multistep forms, or more likely you set your form destination
>> to the page where the next form is.
>>
>



--
Greg Knaddison | 303-800-5623 | http://growingventuresolutions.com
Cracking Drupal - Learn to protect your Drupal site from hackers
Now available from Wiley http://crackingdrupal.com

Re: Using drupal_execute

by Jeff Greenberg-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Greg Knaddison wrote:

> hook_menu elements don't have to be visible as menu choices.
>
>  
Ah. Ok, so I've done this: I created a callback (edited to remove the
description, etc.):
  $items['admin/store/orders/tracking_format'] = array(
    'page callback' => 'drupal_get_form',
    'page arguments' => array('_uc_shipmenttracking_format_form'),
    'type' => MENU_CALLBACK,
    'file' => 'uc_shipmenttracking.admin.inc',
  );
and in the file uc_shipmenttracking.admin.inc I have a
_uc_shipmenttracking_format_form() function that builds the form, and a
_uc_shipmenttracking_format_form_submit() function.

So I would expect when the path 'admin/store/orders/tracking_format' is
invoked, that the _uc_shipmenttracking_format_form function will fire?  
In the first form's submit function, I put a drupal_redirect_form
statement that redirects to 'admin/store/orders/tracking_format', and
when I click submit on the first form, I am sent to Page Not Found.

Thanks, getting close,
Jeff