[development] Multiple Forms, single form handler
David Metzler
metzlerd at metzlerd.com
Wed Jun 20 21:19:12 UTC 2007
The basic way I do this:
function invites_block_form_submit($formid,$form_values)
{
invites_save_invite($form_values);
}
function invites_form_submit($formid,$form_values)
{
invites_save_invite($form_values);
}
function invites_save_invite($fields)
{
// common stuff here
}
It doesn't have to be more complicated than that.
On Jun 19, 2007, at 5:11 PM, James McLean wrote:
> Howdy,
>
> I'm working with a module called 'invite' (not sure if its drupal core
> or not) and i've added some hooks to allow it to work as a block as
> well as a regular module. The block is working fine and I have managed
> to build a form using the standard Drupal forms API successfully.
>
> The form submits to my validate function correctly and validates the
> submitted details as it should.
>
> Now, in order to save time and re-use existing code, I would like the
> form in my block to use the same methods and routines for saving
> information that the main form uses when you view it directly and fill
> out that form and submit that (http://drupal.local/invite/). The main
> form has two fields that are submitted (email address, required -
> description, not required) and my Block form has a single field (email
> address).
>
> The form built in my block is named 'invites_block_form' and the main
> form is named 'invite_form'
>
> I've attempted to use hook_forms() to achieve this behavior as
> outlined in the 'Pro Drupal Development' book but cant quite get my
> head around how to achieve it.
>
> If anyone could provide some insight into how to achieve this I would
> be greatful.
>
> Cheers,
>
> James McLean
More information about the development
mailing list