Force field to have a value

Description of the limitation and why it is relevant to address

As a developer I want to ensure communicate clearly to the user that a field should have a value in a simpler way than now, which requires setting up UserErrors, InputValidations and the like, so that developments are easier and cleaner.

I think this is relevant for the VIKTOR platform because it simplifies developments, and improves user experience.

Submitter proposed design (optional)

Add an argument to the Field, e.g.:

length = vkt.NumberField("Length", default=10, min=1, max=100, allow_empty=False)

When the field is empty, it renders similar to the min/max arguments, highlighting it as red, with the standard message that it requires to be filled.

Current workarounds

  • raise UserError in code
  • InputValidation
  • on_next on next Step

Requested by

@miket

I really like the idea, it’s a lot more intuitive for users, especially new users.

When the field is empty, it renders similar to the min/max arguments, highlighting it as red, with the standard message that it requires to be filled.

We had the same concern. It seems to me if a user open a page and the first thing they see is a page filled with red parameters, it would be a little much.

I would suggest one (or more) of :

  • greying out optional parameters, or make a distinct visual for it
  • making required parameters red only if a view is trying to use them
  • another visual representation; eg, standard * (asterisk next to the field)
  • or even changing entirely how InputValidation is presented in the UI