Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
3698 Tampilan

i have a radio widget, i wanted it as a required field but the `required=True` is not working here.. 
any solution for this? 
vendor_from = fields.Selection([('user', 'User'), ('vendor', 'Vendor')], string="Vendor From")

Avatar
Buang
Jawaban Terbai

Hello Ashutosh

`required=True` should work here in python field declaration.

Alternatively, you can write `required='"1"` in XML file for that field. Try this one it will solve your issue.


Thank you!

Avatar
Buang
Penulis

thank you :)

Jawaban Terbai

Hi,

The required parameter works with the fields when you add it in python field definition or XML code. But, it doesn't work when we use a radio widget for the selection field. If you need to make it required, then you have to provide a default value in the definition. Once you give a default value, it will be there and the only option for the user will be to change it and there will be no option to remove it like the normal dropdown option. Hence the field can be used as a required field. 

For example:

vendor_from = fields.Selection([('user', 'User'), ('vendor', 'Vendor')],
string="Vendor From", default='user')

Regards

Avatar
Buang
Penulis

thank you :)

Post Terkait Replies Tampilan Aktivitas
1
Jun 25
1715
3
Jul 25
3337
1
Mei 25
1480
1
Mei 25
1742
4
Mei 25
2874