Best practice to implement add/update forms?


#1

I’m trying to avoid duplication in my code. In some frameworks, you can implement a model into the form tag and it’ll populate the inputs accordingly. How do you do this in Ember so you don’t have to duplicate a large form twice (once for the add screen and second for the updating/editing screen). I’m trying to do something like this:

{{render "forms/contract" contract}}

The above code will be for the edit and the new code will be similar to: {{render "forms/contract"}}. In the forms/contract.hbs file, I have inputs like: {{input value=fname}} but the editing screen won’t populate with contract.fname unless I physically type that out which I don’t want for my add screen.

Thanks for any input.


#2

You should only need to define your form once and populate it with your model. It might be that your data is not being passed in properly, or the form is not set up correctly, but it’s hard to tell what the problem is from what you’ve described. Can you give some more context? What do you mean by:

the editing screen won’t populate with contract.fname unless I physically type that out


#3

I got it working… model.fname is all I needed.