[development] Using the Forms API to post information to an external source

Greg Knaddison Greg at GrowingVentureSolutions.com
Tue Aug 25 16:42:16 UTC 2009

On Tue, Aug 25, 2009 at 10:34 AM, Brian Vuyk<brian at brianvuyk.com> wrote:
> For one of my clients, we have a long multistep form that we use to collect
> information for a user and enroll him / her in a course. One thing we would
> like to do is POST some information to an external API.
> Is it possible, using the FAPI, to POST data to an external source? I was
> going to user $form['#method'], however, that only allows internal paths.

I don't think so.

> Worst case scenario, I could create a custom submit callback which POSTS the
> data over using CURL, but I am hoping to find a more elegant solution.

Use drupal_http_request over CURL if you must

> Any suggestions?

I would just create it as a static HTML form.  FAPI is helpful when:

1. You are doing form processing 100% in Drupal
2. You are building a form for a shared module and want to allow site
specific modifications via hook_form_alter/theme functions

We know 1 isn't true.  And I assume this is a form that is only useful
for the one specific client site...


Greg Knaddison | 303-800-5623 | http://growingventuresolutions.com
Cracking Drupal - Learn to protect your Drupal site from hackers
Now available from Wiley http://crackingdrupal.com

More information about the development mailing list