If an attribute is set another attribute mandatory

Hello Team,

I have the next issue: if the customer fills an attribute, he must fill another attribute too.
Such kind of:

if(getEditedEntity().getQuDate()!=null){
            //    QuoteValue = @NotNull
            }

Is it possible to do it (programmatically) in Cuba?

Best Regards,
-n

Hi @neutrino,

There is a good post in cuba blog about validation. I suggest you take a look to understand the different approaches.

If you want a quick validation done only in a given screen, you can set that the component is required (see required in the docs). Just inject the component in the controller and set that it is required in the appropriate listener (in your case it may be BeforeCommitChangesEvent or a ValueChangeEvent of another field):

field.setRequired(true);

Regards,
Peterson.

2 Likes