[development] fixing nodeapi : programmatically submitting forms.

Moshe Weitzman weitzman at tejasa.com
Wed Jun 28 21:26:58 UTC 2006


As you say, this is sorely needed. This is a big project, but I'm really 
contemplating giving it a start. I might do a proof of concept. Anyone else 
interested in joining?

Adrian Rossouw wrote:
> Hey everyone.
> 
> I don't have a lot of time for core development right now (I will likely 
> only have time again in august, by the looks of things),
> but we have a problem in core at the moment. I am talking of course of 
> the fact that FAPI only partially replaced node api,
> leaving neither of them the right solution for programmatically creating 
> nodes and the like.
> 
> The solution I have in mind for this , is the following :
> 
> 1 ) introduce a hook_forms. which registers each of the forms on the site.
> 2 ) register all the forms, and their inputs and create callbacks for them
> 3 ) put the form creation code into it's own function, with the 
> registered callback
> 4) alter fapi to not use _POST at all. Instead use a parameter that is 
> passed to it, which merely defaults to _POST.
> 
> Instead of PUSHING the form array through the form generation process, 
> we now have the ability to PULL the form
> array and process it.
> 
> So whenever you want to display a form, instead of having
> 
> function mymodule_page_callback() {
> 
>    $form['title'] = array(
>        /*
>          generate your form array here
>       */
>   );
>   return drupal_get_form('form_id', $form, 'alternate');
> }
> 
> You have :
> 
> function mymodule_forms() {
>    $form['mymodule/form_id'] = array(
>         'callback' => 'mymodule_form_id',
>         'access' => user_access('can do form_id'),
>         'title' => 'form title'
>    );
> }
> 
> function mymodule_form_id($input) {
>    $form['title'] = array(
>         /*
>          generate your form array here
>       */
>   );
>   return $form;
> }
> 
> function mymodule_page_callback() {
>   // get your form input ready
>   return drupal_get_form('mymodule/form_id', array('input' => 'object'));
> }
> 
> 
> 
> -- 
> Adrian Rossouw
> Drupal developer and Bryght Guy
> http://drupal.org | http://bryght.com
> 
> 



More information about the development mailing list