0

I need to have a request form on a D7 site which does a few different things with the form data:

  • Writes to database table (standard);
  • Emails a copy of the form data to a site administrator on a pre-defined email address;
  • Creates a XML file attachment in a prescribed format (not valid XML, so possibly best being a template with placeholder values being replaced by form data) which is also attached to the email to administrator.

The generation of the XML is currently working fine in a bespoke PHP system and I'm thinking for ease re-using the functionality would make good sense.

However, is there a simple way to hook this into the submit process for the Drupal form? I believe using the Forms API may be the best approach?

1

Just implement the hook_form_alter or hook_form_FORM_ID_alter and add your custom submit handler.

See this article for an intro into hooking into forms: http://websmiths.co/blog/very-introduction-drupals-hookformalter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.