lundi 18 septembre 2017

Ember Js nested forms

Currently I have a form called a "form A", I've created a number of views for this form, an edit, create and list. I want to be able to create a form called "form B", that will pull through "form A's ID" as a parent ID. To enable me to have a list of all form B under a "form A" (essential a one to many relationship). So at the moment under my list for "form A" I have this link for each item:

 <!--Link to a controller -->
      <span class="btn btn-primary"> form b </span> 


Here is also my router

 this.route('form-a', function() {
    this.route('new');
    this.route('listing');
    this.route('edit', {path: '/edit/:form-a_id' });
    this.route('form-b', function() {
      this.route('listing', {path: '/listing/:form-a_id'});
      this.route('new');
    });
  });

So I'm trying to pull through the Id of form-a for the listing. However I'm kind of stuck here as I'm unsure how what to do next and how to correctly pull through "form a" Id in the listing controller and the use it as a parent ID for each "form B". Is there a better way to have nested forms with one too many relationships or am I going about it in the best way?

I hope someone can help as this issue as I have hit the coding wall. If you need any clarifications please ask as I know I'm usually terrible at describing my issues.




Aucun commentaire:

Enregistrer un commentaire