Reputation: 8189
Typically in Ember, you declare a form without having to declare the record it's editing. For instance (using Emblem.js):
form
input type="text" value=body
button click="submit"
This works because you've specified the model to be edited in your route. What if the form doesn't have a route associated with it, though? In this case, the form is encapsulated within a component. Within the component, I've created the record and can access it in template as comment
. However, if I try something like this:
form comment
input type="text" value=body
button click="submit"
Then Ember errors. Is there some syntax I don't know about? Something like form record=comment
?
Upvotes: 1
Views: 40
Reputation: 47367
Form itself has nothing to do with it. It's the context of template at that point. In your first example body
is a property in scope in the template.
In your example the property isn't in the scope, but a property on the comment
property.
In handlebars you can change the scope like so
{{#with comment}}
....
{{/with}}
In Emblem
with comment
form
input type="text" value=body
button click="submit"
Additionally if you don't need to change the scope, but just want to bind a property, you can do it like so
form
input type="text" value=comment.body
button click="submit"
Upvotes: 1