[development] drupal_execute

David Cohen drupal at dave-cohen.com
Fri Nov 16 07:41:32 UTC 2007


I'm not sure if this is causing your problem, but it's what I'd try
first.

$form['#submit'] is unfortunately very fragile, in that if someone has
set it before you, you must respect their setting.  Something like:

    // Notify us when form is submitted.
    $submit_cb = array('splitter_submit' => array());
    if (is_array($form['#submit']))
      $form['#submit'] += $submit_cb;
    else
      $form['#submit'] = $submit_cb;

That way you respect any submit callbacks that are already associated
with the form.  It's an easy thing for modules to miss.

-Dave



On Fri, 16 Nov 2007 09:21:18 +0200, "domas" <domas.m at gmail.com> said:
> Hi,
> I was experimenting with drupal_execute, but this set of functions does
> not seem to work the way I expect it to. I change the function the node
> creation form submits to and then try to call drupal_execute to pass the
> values.
> 
> function splitter_form_alter($form_id, &$form) {
>   if ($form_id == 'page_node_form') {
>     $form['#submit'] = array(
>       'splitter_submit' => array()
>     );
>   }
> }
> 
> function splitter_submit($form_id, $form_values) {
>   drupal_execute('page_node_form', $form_values);
> }
> 
> However, this does not seem to work. After I submit, I get a blank page
> and no node is created.
> 
> What am I missing?
> 
> Thanks,
> Domas
> 


More information about the development mailing list