views:

147

answers:

1

I need to write a module that sends order data to an epayment service, similar to say, paypal. They need the data to be submitted from a form with elements that look something like this (notice the duplicate name):

<input name="ORDER_PNAME[]" type="hidden" value="CD Player">
<input name="ORDER_PNAME[]" type="hidden" value="Geanta voiaj 2L">

This makes it impossible to override the form by simply editing $form in module_form_alter() because "ORDER_PNAME[]" would be a duplicate key in $form.

So I need to bypass the whole drupal form handling system. I looked and found that I could overwrite the $form variable in uc_cart_checkout_review with plain html form data (see http://api.ubercart.org/api/function/uc_cart_checkout_review/2 line 4).

What would be the correct way to do this?

A: 

On the rights of a workaround:
you can add the necessary form elements using markup element:

$form['your_name'] = array(
    '#type'  => 'markup',
    '#value' => '<input name="ORDER_PNAME[]" type="hidden" value="CD Player">
                 <input name="ORDER_PNAME[]" type="hidden" value="Geanta voiaj 2L">',
);


If you don't need to redirect user to that e-payment service page, just send data, you can use curl to post the necessary data. A related question: http://stackoverflow.com/questions/2592146/auto-submitting-a-form-curl.

Kniganapolke
Thanks, the markup idea worked great.
Vlad Socaciu