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

How to validate on checkbox ?

未關閉
#969 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
JavaScript
星號
879
分支
327
PR 合併指標
30 天內沒有已合併 PR

描述

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?

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。