CheckBoxList Validator

Hello,

I´m trying to set RequiredValidator on a CheckBoxList in a Form.
CheckBoxList-Value is linked to an PageProperty which represents an array.

But the Validator-warning does not show when I klick form submit button…

When I set the options of the CheckBoxList manually, the RequiredValidator works.
But I want to bind the CheckBoxList-options to an array coming from the database, just like I found here: Dynamic One-to-Many Checkbox List? - the RequiredValidator does not work with those settings.

Is it possible to use the RequiredValidator with my configuration?

Thanks!

Hi @d.kotou,

Try setting the Visible property of both the CheckBoxList and the RequiredValidator to ${yourOptionsProperty != null} where yourOptionsProperty is the page property that contains the checkbox options. This should delay the initialization of the validator until the options are available.

Thank you! :slight_smile: That works perfectly!

Hi @korchev,

i have one more question. When I open the add or edit-page with the CheckBoxList, i get following error in the console:

add-mittelherkunft.component.html:3
ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'component: undefined'. Current value: 'component: [object Object]'.

and

checkboxlist.d.ts.CheckBoxListComponent.html:6 ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ng-valid: true'. Current value: 'ng-valid: false'.

Do you have an idea why this error pops up?

Thank you!

Hi @korchev,
i just solved the error problem.
Thanks!

Hi @korchev,

I still get this error:
Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'component: undefined'. Current value: 'component: [object Object]'
when I open the Edit or Add Page.
I never had this problem, so i assume it has to do with the checboxlist(its the first time im using it).

Do you have any idea how to fix this?

Thank You!