[development] Forms API II: Return of the Chx (you really need
to read this)
Stefan Borchert
stefan at borchert.cc
Fri Aug 18 20:39:51 UTC 2006
Adrian Rossouw schrieb:
> 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'<%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.
>
Hm, what about "GET"? Don't know, when I would use it, but perhaps...
One could use your suggestion as a shorthand for
$form['#*post*']['edit'] and if "GET" is needed you have to use the long
version ($form['#get']['somethingtoset']). Or is this to much magic?
More information about the development
mailing list