I'm new to Angular Schema Form and having some issues with select
and checkbox
fields required
validation.
Under $scope.schema
I have the select field named designation
:
"designation": {
"title": "Designation",
"type": "select",
"default": undefined
}
$scope.form
(declaring designation
and agreeTerms
):
{
"key": "designation",
"type": "select",
"title": "Designation",
"titleMap": [
{ value: undefined, name: "Select a designation" }, // first value
{ value: "Andersson", name: "Andersson" },
{ value: "Johansson", name: "Johansson" },
{ value: "other", name: "Something else..."}
]
},
{
"key": "agreeTerms",
"type": "checkbox",
"title": "I agree to ..."
}
Both designation
and agreeTerms
are defined in the schema's required
property.
When I submit the form, both fields however pass the required
validation. What I'm expecting the UI to show are the Required
messages underneath/after the fields. That is not happening.
Things I've tried:
- assign first value of the select field to
''
andnull
and match that with the schema default value. - change the
select
field type toobject
in the schema; this worked and passed the required validation but the property didn't show up in the model
Please help :)