petkopara / PetkoparaCrudGeneratorBundle

Symfony3 CRUD generator bundle with pagination, filter, bulk actions and Twitter bootstrap 3.3.6 features.
MIT License
70 stars 17 forks source link

some defaults Controller actions have wrong params #27

Closed pesseyjulien closed 7 years ago

pesseyjulien commented 7 years ago

Hi,

It seems that the bundles generates some errors. For example, the following action cannot work :

 /**
     * Finds and displays a Liendefinition entity.
     *
     * @Route("/{id}", name="liendefinition_show")
     * @Method("GET")
     */
    public function showAction(Liendefinition $liendefinition)
    {
        $deleteForm = $this->createDeleteForm($liendefinition);
        return $this->render('liendefinition/show.html.twig', array(
            'liendefinition' => $liendefinition,
            'delete_form' => $deleteForm->createView(),
        ));
    }

The route is define to receive an 'id', but the action function expect an Object, which is not possible.

Instead, it should be something like this :

 /**
     * Finds and displays a Liendefinition entity.
     *
     * @Route("/{id}", name="liendefinition_show")
     * @Method("GET")
     */
    public function showAction($id)
    {
        $em = $this->getDoctrine()->getManager();
        $Liendefinition = $em->getRepository('Liendefinition')->find($id);

        $deleteForm = $this->createDeleteForm($liendefinition);
        return $this->render('liendefinition/show.html.twig', array(
            'liendefinition' => $liendefinition,
            'delete_form' => $deleteForm->createView(),
        ));
    }

Is it possible to fix this ?

Also, the following are more enhancements considerations than bugs, but it would be cool if we could choose where to put the show/edit/delete column. For now, it's a the end of the table, but with entities with a lot of fields, you need to scroll quit a lot to access it. It would also be cool if we could choose where to send the views, for example inside a bundle.

Thanks, Julien

petkopara commented 7 years ago

Hi @pesseyjulien , Thank you for the feedback.

The show code is working fine, if you have SensioFrameworkExtraBundle installed. Because I am using the @ParamConverter feature. For now the SensioFrameworkExtraBundle is coming with the default installation of Symfony, so shouldn't be a problem. Eventually maybe is a good idea to remove this dependency.

About the columns on show edit and delete - Opened new feature issue #28. This enhancement is questionable because I think I will run from the original idea of the crud generator(Generate and edit after that). On the other side there is a lot of admin generators that depends on configurations and they are more complex for use. But as long as these options can be passed through the console and keep the bundle simple to use, I can implement it.

There is already option to save the views inside the bundle --bundle-views.