Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
1142 Zobrazení

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
Zrušit
Nejlepší odpověď
required="True"

Try like this. T must be capital.

Avatar
Zrušit
Autor

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.

Nejlepší odpověď

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

Avatar
Zrušit
Autor

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 Odpovědi Zobrazení Aktivita
0
bře 23
207
1
zář 24
3661
1
srp 22
6261
0
čvc 20
2794
1
bře 15
2843