跳至內容
選單
此問題已被標幟
5 回覆
13822 瀏覽次數

How i can get values from checkboxes with the same name in the controller (get method)?

For example:

<li t-foreach="attr.values" t-as="value">

<input onchange="submit()" type="checkbox" t-att-value="value.name" t-att-name="attr.name" checked="checked" /> <t t-esc="value.name" /> 

</li>

 



頭像
捨棄
最佳答案

Answering more or less so I can find how to do this if I forget where in my code it is and hope it'll help others.

This works in odoo 10

Template:

<t t-foreach="users_projects" t-as="project">
	<p><input type="checkbox" name="projects" multiple="multiple" t-att-value="project.id"/> <t t-esc="project.name"/></p>
</t>

Controller

selected_list = request.httprequest.form.getlist('projects')
頭像
捨棄

This solution still holds good for odoo15. Thanks, Samo.

作者 最佳答案

Ummm i solved it but in a ugly way.... playing with the name of the checkboxes... :\


Can use something like "name=mylist[]"?

頭像
捨棄

Hello, how to use this?

相關帖文 回覆 瀏覽次數 活動
2
2月 16
6771
3
9月 17
11620
2
2月 16
10625
2
5月 24
1855
1
11月 22
2846