[support] hook_forms and theming

Ivan Sergio Borgonovo mail at webthatworks.it
Tue Jan 29 17:53:19 UTC 2008


On Tue, 29 Jan 2008 09:19:38 -0800
"Metzler, David" <metzlerd at evergreen.edu> wrote:

> I tend to just call them...  There's no real reason to rename it is
> there? 
> 
> $items[] = array('path'=>'foo', 'callback' => 'mymodule_foo
> $items[] = array('path'=>'foo2', 'callback' => 'mymodule_foo2
> function mymodule_foo()
> {
>   .... some code....
>   $output .= drupal_get_from('mymodule_myform1'); 
>   return $output; 
> }
> 
> function mymodle_foo2()
> {
>   .... some different code ...
>  $output .= drupal_get_form('mymodule_myform1'); 
>  return $output; 
> }

> Or are you talking aobut some other type of reuse? Am I missing
> something here? 

form theme function reuse.

the hook_form let reuse the form but with different _validate and
_submit... but different theme function too (unless I'm missing
something).

For form reuse hook_forms is a bit smarter than defining aliases
(function that just call other functions), since you can build the
alias automatically.

form_a, form_b and form_c will actually use the same $form but with
different _validate and _submit functions... but with different theme
function too... and it doesn't make too much sense to me... unless
I'm missing some parameter...

I'd say you could alias the callback *and* the theming function... so
in the hook_form you'd decide which code each "form" (considered as
the tuple $form, _validate, _submit, theme_) have to share.


-- 
Ivan Sergio Borgonovo
http://www.webthatworks.it



More information about the support mailing list