如何覆盖 ubercart 中的 review_cart 表单
我需要编写一个模块,将订单数据发送到电子支付服务,类似于贝宝。他们需要从包含如下元素的表单提交数据(注意重复的名称):
<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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于解决方法的权利:
您可以使用标记元素添加必要的表单元素:
如果您不需要将用户重定向到该电子支付服务页面,只需发送数据,您可以使用curl来发布必要的数据。相关问题:自动提交表单 (cURL)。
On the rights of a workaround:
you can add the necessary form elements using markup element:
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).