Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
6517 Lượt xem

I have following code inside my website form:


<form id="custom_form" class="container-fluid">
    <div class="form-group row form-field o_website_form_required">
        <input type="checkbox" class="form-control o_website_form_input" name="test" required=""/>
    </div>
    <div class="form-group row">
        <div class="offset-lg-3 offset-md-4 col-md-8 col-lg-7">
            <a href="#" role="button" id="send" class="btn btn-primary btn-lg o_website_form_send">Send</a>
            <span id="o_website_form_result" class="text-danger ml8"></span>
        </div>
    </div>
</form>


But when I'm clicking save without even touching the checkbox the form ignores it and does not care if checkbox i unchecked.

But when I check it and then uncheck it again (so it should be again in its initial state) it is actually wotking and form will not pass.


What Am I doing wrong? What property is changed when I'm clicking the checkbox twice versus its initial state? It should not make a difference...


Using Odoo13

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello Marcus,

you can create one Selection field and give widget Many2many Checkboxes  or you can use widget radio

demo_field = fields.Selection([('check_demo', 'Check Demo')], string='Demo')

you can also give required in python side as well as on the XML side.

<field name="demo_field" widget="many2many_checkboxes" required="1"/>

Thank you.


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 5 25
9713
3
thg 3 24
5348
1
thg 1 21
3398
2
thg 4 22
4208
0
thg 1 25
1135