콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
5 답글
13300 화면

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?

관련 게시물 답글 화면 활동
2
2월 16
6395
3
9월 17
11179
2
2월 16
10192
2
5월 24
1490
1
11월 22
2564