Symfony Design Question - How Can I Share Forms Between Applications?

I am developing a site in Symfony, and I'm not sure which is the best way to handle this scenario.

I am creating a party ordering system. Anyone can go to my interface and send a new reservation. Once they end, they just get a confirmation screen, they cannot edit it. Easy.

Only some users will be able to access the administrative application (it could be protected simply by being on the intranet, but this is not important, just assume that it will be available only to admin users). They will be able to view a list of submitted orders. Easy.

My problem is code reuse, allowing administrators to edit existing orders. When you run generate-modulein Symfony, the generated module (which, like the newbie I accept, is a good example of structuring things), creates the form as partial. I had to configure this form for my use (a lot of Javascript, etc.), so of course I want to reuse this code in order to be able to load an existing reservation into this form. But there seems to be no way to share this partial between applications (I saw people mentioning creating a plugin ... but it seems complicated for this use).

I considered using an IFrame to load a form from the interface and simply pass the "id" parameter to load in edit mode, but that would mean that the edit mode is unsafe - anyone can go to the form on the frontend and pass this parameter to change the reservation.

I also considered the possibility of entering all the form display code (HTML, Javascript, etc.) in the method of the form object, but this is not like MVC - all the displayed code is then in the form. But this is only because I think of the form in the same way as a model - is that right?

I feel this should be a normal situation. You can share models and forms between applications, why can't you share this common form display code?

Thank!

+3
source share
2 answers

, 2 . , i18n, . 1 . . .

+1

, , , (frontend backend), , - ...

0

All Articles