How is that possible to keep a component required in readonly mode?


I have a form with some TextButtonFields, it basically has a button on right side of the TextField, so I usually set these fields as readonly but in Vaadin, when we set a field as readonly it removes required = true
I’m trying to debug Vaadin lib to understand where I can override that to keep required = true in a readonly field but until now I was not able to find that.

Please, does anybody have any idea?

I’m wondering why do you need to have required=true, for read-only field, meaning that user can’t edit this field.
Let’s say even if this read-only fields are filled from other part of the code, and let’s you managed to set them required=true. And checking will fail, and the user will get a message that this field a mandatory, but he still can’t edit them. So it’s really a confusing behaviour.
If the required values are not coming from the user input, but from other place let’s say database, you should check these values as soon as you get them.

If you want to change only the appearence of the field (adding an asterix to the required field) you should do this via css.

Hello Dmitrii, I appreciate your feedback.

The TextButtonField is a common TextField with an Extension Button, so you dont need to use field indeed, just the button in the right side as you can see in the below attachment.

It’s a bit different of the common use.