[development] fixing nodeapi : programmatically submitting forms.
Neil Drumm
drumm at delocalizedham.com
Sat Jul 1 00:37:01 UTC 2006
Adrian Rossouw wrote:
> 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
What would this list be used for?
> 3 ) put the form creation code into it's own function, with the
> registered callback
Maybe in it's own file too, along with ..._validate, ..._submit, etc.
Less code to include up front. Something along the lines of
path_to_module/forms/form_id.form.php would get auto-included.
> 4) alter fapi to not use _POST at all. Instead use a parameter that is
> passed to it, which merely defaults to _POST.
Would the form creation code need to set #value itself then?
> function mymodule_forms() {
> $form['mymodule/form_id'] = array(
> 'callback' => 'mymodule_form_id',
> 'access' => user_access('can do form_id'),
Shouldn't this be handled in ..._validate() or hook_menu()?
> 'title' => 'form title'
What would the title do?
> );
> }
>
> function mymodule_form_id($input) {
I would go ahead and put _form on the end of that function name.
> $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'));
> }
--
Neil Drumm
http://delocalizedham.com/
More information about the development
mailing list