[development] Forms API II: Return of the Chx (you really need toread this)

Jeff Eaton jeff at viapositiva.net
Fri Aug 18 20:39:22 UTC 2006


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 at bryght.com] 
Sent: Friday, August 18, 2006 3:31 PM
To: development at drupal.org
Subject: Re: [development] Forms API II: Return of the Chx (you really
need toread this)




On 8/18/06, Jeff Eaton <jeff at 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 at example.com'
<mailto:%27robouser at example.com%27> ;
  $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. 





-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20060818/ff3a0234/attachment.htm


More information about the development mailing list