Skip to Content
Menu
This question has been flagged

Hi. I'm adding a select for the request_rma view and it works but it doesn't make it mandatory. I'm trying to add required="", required="true" or required="required", as usually in html. Is something different to make this in odoo?


select required="required" name="tag_ids" class="form-control o_website_form_select">
option>---/option>
    t t-foreach="request.env['rma.tag'].sudo().search([], order='id asc')" t-as="tag">
        option t-att-value="tag.id">
​ ​t t-esc="tag.name"/>
​​/option>
/t>
/select>

UPDATE: As I can see, if I use option>---/option> instead of a void text it works but I get a generic error message "An error has occured, the form has not been sent" so it doesn't seem the correct solution. This message is no elegant at all to the user.
Avatar
Discard
Best Answer
required="True"

Try like this. T must be capital.

Avatar
Discard
Author

I used required="" because the other fields in the form were in this way. However, if I use required="True" nothing changes.

I tested more and the problem is not what to put inside required="", is that if the option has no text it doesn't evaluate it and continues. I jus tried and if i put <option>---</option> then I get the error message "An error has occured, the form has not been sent.". If I choose an option then the form is sended fine.

So, can I put an empty option (with no text and no value) in any way? Because it's not elegant see this kind of error.

Best Answer

I test when adding select field in website editor, they add required="1" so you should try that

Avatar
Discard
Author

I tried required="1" too and nothing changes.

As I said to @Aravind S, I tested more and the problem is not what to put inside required="", is that if the option has no text it doesn't evaluate it and continues. I jus tried and if i put <option>---</option> then I get the error message "An error has occured, the form has not been sent.". If I choose an option then the form is sended fine.

So, can I put an empty option (with no text and no value) in any way? Because it's not elegant see this kind of error.

Related Posts Replies Views Activity
0
Mar 23
207
1
Sep 24
3504
1
Aug 22
6022
0
Jul 20
2592
1
Mar 15
2763