Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are the required field and custom validation supported for dropdown fields? #9

Open
ofarganc opened this issue Jan 25, 2023 · 2 comments

Comments

@ofarganc
Copy link

ofarganc commented Jan 25, 2023

We are trying to make a dropdown field mandatory but it does not work.
Example of dropdown with required

   @Property(label = "Highlight Type", description = "Defines the type of the highlight.", order = 2, property = {
            "required=true",
            "widgetType=dropdown",
            "dropdownOptions=["
                    + "{'value':'thread','description':'Thread'},"
                    + "{'value':'event','description':'Event'},"
                    + "{'value':'video','description':'Video'},"
                    + "{'value':'podcast','description':'Podcast'},"
                    + "{'value':'article','description':'Article'}"
                    + "]"
    })
    String type() default StringUtils.EMPTY;

Example of dropdown with custom validation class.

    @Property(label = "Highlight Type", description = "Defines the type of the highlight.", order = 2, property = {
            "validation=highlight-type-mandatory",
            "validationMessage=Highlight Type field is mandatory.",
            "widgetType=dropdown",
            "dropdownOptions=["
                    + "{'value':'thread','description':'Thread'},"
                    + "{'value':'event','description':'Event'},"
                    + "{'value':'video','description':'Video'},"
                    + "{'value':'podcast','description':'Podcast'},"
                    + "{'value':'article','description':'Article'}"
                    + "]"
    })
    String type() default StringUtils.EMPTY;

Is this supported or will it be in the future?
Many thanks.

@stefanseifert
Copy link
Member

no, currently only "text-based input fields" are supported (as of https://wcm.io/caconfig/editor/validation.html, probably not written explicitly enough), that means text field, text area, pathbrowser.

it would be great to extend the validation support for dropdown fields, but it will be a bit tricky due to the combination of AngularJS and Granite UI. PRs would be welcome!

please note there is also a special property "required" to apply a required validation, this is easier then using a custom validation. but iirc it's also currently not supported for dropdown field for same reason.

i will take a not to improve the documentation around this.

@ofarganc
Copy link
Author

many thanks for the quick reply @stefanseifert ! We'll take a look and see if we can come up with a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants