Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
5 Răspunsuri
13459 Vizualizări

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>

 



Imagine profil
Abandonează
Cel mai bun răspuns

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')
Imagine profil
Abandonează

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

Autor Cel mai bun răspuns

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


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

Imagine profil
Abandonează

Hello, how to use this?

Related Posts Răspunsuri Vizualizări Activitate
2
feb. 16
6509
3
sept. 17
11334
2
feb. 16
10369
2
mai 24
1635
1
nov. 22
2650