Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
6620 มุมมอง

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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.


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
พ.ค. 25
9799
3
มี.ค. 24
5451
Website form field conditions แก้ไขแล้ว
1
ม.ค. 21
3477
2
เม.ย. 22
4285
0
ม.ค. 25
1205