I m having an issue with forms in ember, the this.getProperties
inside controller returns undefined
for all properties. Here is my code:
settings.hbs:
<form {{action 'saveSettings' on='submit'}}>
<label for="email">Email</label>
<p>
{{input id='email' placeholder='Enter Email' value=model.email}}
</p>
<label for="name">Name</label>
<p>
{{input id='name' placeholder='Enter Name' value=model.name}}
</p>
<label for="surname">Surname</label>
<p>
{{input id='surname' placeholder='Enter Surname' value=model.surname}}
</p>
<label for="skype">Skype</label>
<p>
{{input id='skype' placeholder='Enter Skype' value=model.skype}}
</p>
<label for="phone">Phone</label>
<p>
{{input id='phone' placeholder='Enter Phone' value=model.phone}}
</p>
<label for="city">City</label>
<p>
{{input id='city' placeholder='Enter City' value=model.city}}
</p>
<label for="country">Country</label>
<p>
{{input id='country' placeholder='Enter Country' value=model.country}}
</p>
<button type="submit">Save Settings</button>
</form>
settings.js (controller)
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
saveSettings() {
let {
email, name, surname, skype, phone, city, country
} = this.getProperties('email', 'name', 'surname', 'skype',
'phone',
'city', 'country');
var user = this.get('model');
user.set('email', email);
user.set(
'name', name);
user.set('surname', surname);
user.set('skype',
skype);
user.set('phone', phone);
user.set('city', city);
user
.set('country', country);
user.save();
}
}
});
settings.js (route)
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.find('user', 'me');
}
});
When load the page all inputs shows the correct value, but when submit the form all properties are null. I take a few hours stuck here and i don't see why it is not working.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire