Hello, i've got difficulties to set a form field manually as required: ```

Hello,
i’ve got difficulties to set a form field manually as required:

formFactory.setFieldProvider("userName", user -> {
            var textFieldUser = new TextField();
            textFieldUser.setLabel("Name");
            textFieldUser.setRequired(true);
            textFieldUser.setRequiredIndicatorVisible(true);
            textFieldUser.setErrorMessage("This field is required");
            return textFieldUser;
        });

The blue dot appears, indicating that the field is required, but when I push “Add” on the form, the required is ignored and the form closes saying item saved.

What am I doing wrong? I don’t want to update the model class with @NotNull.

Thanks for your help!

The setRequiredIndicatorvisible is only a visual feature. If you want to use bean validation, see the documentation of this add-on in the main page. Cheers!