I think it should be possible. For now, it's very useful to have a flag *in the form itself* that indicates that it's a programmatic submission (ie, isset($form['#post'])).
 
It's definitely something to explore in a subsequent patch.
 
--Jeff
-----Original Message-----
From: Adrian Rossouw [mailto:adrian@bryght.com]
Sent: Friday, August 18, 2006 3:31 PM
To: development@drupal.org
Subject: Re: [development] Forms API II: Return of the Chx (you really need toread this)



On 8/18/06, Jeff Eaton <jeff@viapositiva.net> wrote:

function mymodule_create_user() {
  // register a new user
  $form = drupal_retrieve_form('user_register');
  $form['#post']['edit']['name'] = 'robo-user';
  $form['#post']['edit']['mail'] = 'robouser@example.com';
  $form['#post']['edit']['pass'] = 'password';
  drupal_process_form('user_register', $form);
This is awesome, but do we really need the '#post']['edit'] for every element ?

for shorthand, couldn't we just do

$edit = drupal_retrieve_post('user_register');
$edit['name'] = 'robo-user';
$edit['mail'] = 'something';
$edit['pass'] = 'blah';
drupal_process_form('user_register', $edit);

You could have this as a wrapper of the functionality you mentioned above even.