İçereği Atla
Menü
Bu soru işaretlendi
5 Cevaplar
13510 Görünümler

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>

 



Avatar
Vazgeç
En İyi Yanıt

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')
Avatar
Vazgeç

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

Üretici En İyi Yanıt

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


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

Avatar
Vazgeç

Hello, how to use this?

İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Şub 16
6558
3
Eyl 17
11367
2
Şub 16
10396
2
May 24
1682
1
Kas 22
2689