Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
5 Risposte
13482 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona

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

Autore Risposta migliore

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


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

Avatar
Abbandona

Hello, how to use this?

Post correlati Risposte Visualizzazioni Attività
2
feb 16
6530
3
set 17
11351
2
feb 16
10383
2
mag 24
1659
1
nov 22
2666