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

Programmatically 'touch' input

Aperta
#409 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
879
Fork
327
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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!

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.