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?

贡献指南

打开贡献指南

调研方向

The issue provides only model and template snippets; start by tracing ember-cp-validations' presence validator and paper-checkbox's value/onChange behavior. Confirm how the unchecked state is represented and how form.isInvalid is derived, then verify that the submit button is disabled until isAcceptance is checked.

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript
领域
frontend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。