你必须写在表单中选择选项,并在表单动作你会得到选择值。如果你更新代码的问题,我们可以帮你
<form action="/xxxxx" method="POST" id="unique_id">
<select style="width: 200px" id="dropdown">
<option value="volvo">Value1</option>
<option value="saab">Value2</option>
</select>
</form>
在HTTP控制器
@http.route(['/xxxx'], type='http', website=True, auth='public')
def func(self,**post):
print post, "Here Check post values"
工作实例测试:
<form method="post" action="/website_payment/delete/">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
<div class="form-group">
<select name="delete_pm_id" class="form-control" >
<t t-foreach="pms" t-as="pm">
<option t-att-value="pm.id" t-esc="pm.name"/>
</t>
</select>
</div>
<div class="clearfix"></div>
<button class="btn btn-primary">Delete <span class="fa fa-long-arrow-right"></span></button>
</form>
@http.route(['/website_payment/delete/'], methods=['POST'], type='http', auth="user", website=True)
def delete(self, delete_pm_id=None):
if delete_pm_id:
pay_meth = request.env['payment.method'].browse(int(delete_pm_id))
pay_meth.unlink()
return request.redirect('/my/payment_method')
我只是用Xml代码更新我的问题,因为在Python中我不知道如何从这个Xml中获取选项值。我在其他网页上阅读,http.request可能是必要的,但我很困惑。 – SirGuacamole
不起作用,当我运行该函数时,我得到以下输出:{}这里检查帖子值,但不是在下拉列表中选择的选项值(选择标签) – SirGuacamole
给名称选择字段 –