From the example in form.inc:

// Create a new node
$form_state = array();
$node = array('type' => 'story');
$form_state['values']['title'] = 'My node';
$form_state['values']['body'] = 'This is the body text!';
$form_state['values']['name'] = 'robo-user';
drupal_execute('story_node_form', $form_state, $node);

doesn't submit the node, as it results in a preview instead of a node submit.

Adding in 'Submit' as the op in the $form_state values works properly:
eg

$form_state = array();
$node = array('type' => 'story');
$form_state['values']['title'] = 'My node';
$form_state['values']['body'] = 'This is the body text!';
$form_state['values']['name'] = 'robo-user';
$form_state['values']['op'] = 'Submit';
drupal_execute('story_node_form', $form_state, $node);

Should there be a option to define a default form button for #programmed forms?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

Status: Active » Reviewed & tested by the community
FileSize
871 bytes

Let's just doc this.

chx’s picture

Let's just doc this.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed #1.

Anonymous’s picture

Status: Fixed » Closed (fixed)