Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
5 ตอบกลับ
13807 มุมมอง

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?

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.พ. 16
6737
3
ก.ย. 17
11609
2
ก.พ. 16
10608
2
พ.ค. 24
1849
1
พ.ย. 22
2811