Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comment | File | Size | Author |
---|---|---|---|
#2 | drupal_execute_doc-145251-1_0.patch | 0 bytes | chx |
#1 | drupal_execute_doc-145251-1.patch | 871 bytes | chx |
Comments
Comment #1
chx CreditAttribution: chx commentedLet's just doc this.
Comment #2
chx CreditAttribution: chx commentedLet's just doc this.
Comment #3
Gábor HojtsyThanks, committed #1.
Comment #4
(not verified) CreditAttribution: commented