تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
1081 أدوات العرض

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.
الصورة الرمزية
إهمال
أفضل إجابة
required="True"

Try like this. T must be capital.

الصورة الرمزية
إهمال
الكاتب

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.

أفضل إجابة

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

الصورة الرمزية
إهمال
الكاتب

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.

المنشورات ذات الصلة الردود أدوات العرض النشاط
0
مارس 23
207
1
سبتمبر 24
3601
1
أغسطس 22
6195
0
يوليو 20
2663
1
مارس 15
2825