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

Programmatically 'touch' input

Aberta
#409 4 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
JavaScript
Estrelas
879
Forks
327
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

I have a form with several validated inputs and a submit button.

When the form is valid, the button submits the form

When the form is invalid, I want to expose all errors on inputs to the user, even if an input is untouched.

Is there a way to send an 'isTouched' event to the input component?

My current implementation involves a bound property and an action which explicitly sets the isTouched value to true:

``` hbs
template.hbs:

{{paper-input
label="Location"
isTouched=model.locationTouched
value=model.form.location
onChange=(action (mut model.form.location))
errors=(v-get model.form 'location' 'messages')
}}

{{#if (v-get model.form 'isValid')}}
{{paper-button type="submit" raised=true primary=true label="Send"}}
{{else}}
{{paper-button onClick="triggerValidation" raised=true label="Send"}}
{{/if}}
```

``` js
fom-validation.js:

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

export default Ember.Object.extend(Validations);
```

``` js
controller.js:

actions: {
triggerValidation() {
this.get('model').setProperties({
locationTouched: true
});
}
}
```

Thanks for the fantastic work on this lib!

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.