Is there a smarter way to recycle the same form and same themeing function other than hook_forms + aliasing the theme function:
function mymodule_forms() { $forms['mymodule_myform2']=Array( 'callback'=> 'mymodule_myform1', ); return $form; }
function theme_mymodule_myform2($form) { return theme_mymodule_myform1($form); }
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?
Dave
-----Original Message----- From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Ivan Sergio Borgonovo Sent: Tuesday, January 29, 2008 8:21 AM To: support@drupal.org Subject: [support] hook_forms and theming
Is there a smarter way to recycle the same form and same themeing function other than hook_forms + aliasing the theme function:
function mymodule_forms() { $forms['mymodule_myform2']=Array( 'callback'=> 'mymodule_myform1', ); return $form; }
function theme_mymodule_myform2($form) { return theme_mymodule_myform1($form); }
On Tue, 29 Jan 2008 09:19:38 -0800 "Metzler, David" metzlerd@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.