Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
5 Odpowiedzi
13817 Widoki

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>

 



Awatar
Odrzuć
Najlepsza odpowiedź

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')
Awatar
Odrzuć

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

Autor Najlepsza odpowiedź

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


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

Awatar
Odrzuć

Hello, how to use this?

Powiązane posty Odpowiedzi Widoki Czynność
2
lut 16
6751
3
wrz 17
11615
2
lut 16
10619
2
maj 24
1852
1
lis 22
2841