如何覆盖 ubercart 中的 review_cart 表单

发布于 2024-08-27 19:41:09 字数 612 浏览 4 评论 0原文

我需要编写一个模块,将订单数据发送到电子支付服务,类似于贝宝。他们需要从包含如下元素的表单提交数据(注意重复的名称):

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

这使得无法通过简单地在 module_form_alter() 中编辑 $form 来覆盖表单,因为“ORDER_PNAME[]”将是$form 中的重复键。

所以我需要绕过整个 drupal 表单处理系统。我查看并发现我可以使用纯 html 表单数据覆盖 uc_cart_checkout_review 中的 $form 变量(请参阅 http://api.ubercart.org/api/function/uc_cart_checkout_review/2 第 4 行)。

这样做的正确方法是什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥有 2024-09-03 19:41:09

关于解决方法的权利:
您可以使用标记元素添加必要的表单元素:

$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">',
);

如果您不需要将用户重定向到该电子支付服务页面,只需发送数据,您可以使用curl来发布必要的数据。相关问题:自动提交表单 (cURL)

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: Auto Submitting a form (cURL).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文