adopted-ember-addons / adopted-ember-addons/ember-paper

How to validate on checkbox ?

Open
#969 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
879
Forks
327
PR merge metrics
No merged PRs in 30d

Description

Hi, I have `checkbox` using `paper-checkbox` and validation form using `ember-cp-validation`, but I get the `form.isInvalid` set to `true` even if I haven't click to checkmark it ?

model

```
import DS from 'ember-data';
import attr from 'ember-data/attr';
import { validator, buildValidations } from 'ember-cp-validations';
import { computed } from '@ember/object';

const { Model } = DS;

const Validations = buildValidations({
premiumType: validator('presence', true),
isAcceptance: validator('presence', true)
});

export default Model.extend(Validations, {
premiumType: attr('string'),
isAcceptance: attr('string')
});
```

template

```
{{#paper-form as |form|}}
{{paper-input label="Premium" value=model.premiumType onChange=(action (mut model.premiumType)) errors=model.validations.attrs.premiumType.messages}}
{{paper-checkbox label="Required" value=model.isAcceptance onChange=(action (mut model.isAcceptance)) errors=model.validations.attrs.isAcceptance.messages}}

{{#form.submit-button disabled=form.isInvalid primary=true raised=true}}
Submit
{{/form.submit-button}}
{{/paper-form}}
```

What I would expect is: the submit button should be Enabled when the validations are valid; but I get the the button already Enabled even if the checkbox has not been checked... Any help?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.