Symfony Edit Form Using Popup On listing Page

1.6k Views Asked by At

I am displaying the List of Record using KNPPaginationBundle. What I want to edit these record in popup model while staying on the same list page. I have read about it. A Lot of people are doing this using jquery. But i wanted to this in Symfony Way.

Is it possible to have edit form on listing page?

3

There are 3 best solutions below

1
On

You have to use Ajax to edit records and staying in the same page so you have to use jquery

0
On

As @NinjaTN say you need to use ajax to use popup. If you don't want to use ajax you need to send user on form view via an edit button on your listing view.

Form from Symfony doc

or you can use bundle like easyadmin

Another way will be to populate your form on clickevent from your listing grid, send with JS all element you need to your form and then show your popup.

0
On

At first you're mixing two different things. Symfony is only php framework, nothing to do with jQuery or javascript. So with symfony you cannot do things as you can do with jQuery.

If you want to do this without jQuery that means you want to do it without javascript in plain twig? If so you have to render a form for each row in a modal window.

If you want to use javascript without an ajax request, you can do this:

  1. Render a one edit form on a list page.
  2. When user choose row to edit, display a modal window and change at least the id in a route with javascript.
  3. After submitting, be sure that edit action will redirect user back to the list.

If this is your definition on "stay on page", you're done. If it's not you cannot do this without ajax and symfony will not help you, because it has no "javascript support".