Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using {{#em-form}} #57

Open
yazoury opened this issue Nov 2, 2014 · 4 comments
Open

using {{#em-form}} #57

yazoury opened this issue Nov 2, 2014 · 4 comments

Comments

@yazoury
Copy link

yazoury commented Nov 2, 2014

How can I use {{#em-form}},What JS should I add to the project in order to implement the form ??
Thanks and sorry for disturbing .

@davegreco
Copy link

@yazoury pulled from the documentation that I am linking below.
http://indexiatech.github.io/ember-forms/#/getstarted

Getting Started
Installing via bower is the simplest form:

bower install --save ember-forms
Include Bootstrap for styling

Include Ember Forms <script src="bower_components/ember-forms/dist/globals/main.js"> That being said, as a newbie to ember I was also a little lost on where to go from here. The key for me after setting that up using bower was to do this. I added this to my Brocfile.js to have it be included in my ember build. app.import('bower_components/ember-forms/dist/globals/main.js'); I also added this because I am using ember-validations. app.import('bower_components/ember-validations/index.js'); Then I added this to my index.html file for styling. Let me know if you are still having trouble, I'll try to assist all that I can. The key for me though was adding the app import in my Brofile.js I hope that this helps you.

@soundarapandian
Copy link

@yazoury I followed your steps in ember-cli app. Form is rendering but the model validations are not triggered. Below is the code I use for model.

import DS from "ember-data";

export default DS.Model.extend({
  title: DS.attr("string"),
  description: DS.attr("string"),
  created_at: DS.attr("date"),
  validations: {
    title: true,
    description: true
  }
});

and the view is

{{#em-form model=list class="col-md-5"}}
  {{em-input property="title" label="Title" placeholder="Title"}}
  {{em-text property="description" label="Description" placeholder="Description"}}
{{/em-form}}

Any idea?

@lexdon
Copy link

lexdon commented Dec 5, 2014

@soundarapandian If you take a look at the examples at https://github.com/dockyard/ember-validations, you'll see that your validations need to be declared like this:

export default DS.Model.extend({
  title: DS.attr("string"),
  description: DS.attr("string"),
  created_at: DS.attr("date"),
  validations: {
    title: { presence: true },
    description: { presence: true }
  }
});

@soundarapandian
Copy link

@lexdon You are correct. I have resolved this issue few days before. Thank you for your response. 💚

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants