I am working on a Laravel 4 project where I have several models. Some of them are related to others.
For example I have a tour model with several properties and a peak model with several properties which is related to the tour model (m:n).
I created resource controllers to manage each model according to CRUD, which works fine. So every model has its own form to edit and store its own properties as well as relations to existing peaks.
As there is a "main" model (the tour model) I want to give the user the ability to create a peak out of the "create-a-tour"-form if the actually created tour has a peak, which is not yet in the database.
I am thinking about three solutions:
- Open a modal with the peak-form and append the new peak to the select-peak element in the tour-form
- Add the peak-form elements dynamically via AJAX to the tour-form and post the filled data via AJAX to the PeaksController and append the new peak to the select-peak element in the tour-form.
- Add a link to the peaks-form and save the filled information of the tour-form in a session variable, so that the user can add a new peak and then come back to the tour-form where the script fills the data from the session.
What is best practice to solve this? Is there another (better) way to do this? I think that's a common problem, but I didn't find any tutorial or information regarding this question (might be a problem, that I really don't know what to search for in this case).
I appreciate any answer and discussion!
Aucun commentaire:
Enregistrer un commentaire