Search code examples
formsentitysymfony4

Generate Form from exist Entity Symfony4


I have a table in the database which has a large number of columns. I know that EasyAdminBundle is out there and I used it in the past to create forms based on database tables. How can create this based on Entity? So that I can generate the forms automatically and no populate them manually.


Solution

  • You can use the Symfony Maker Bundle. With this bundle, you can generate code if you are using a version of Symfony later than 3.4. For older versions you can use Sensio Generator Bundle.

    In your case, install the Maker Bundle with composer:

    composer require symfony/maker-bundle --dev
    

    Then run this command (and follow the steps) to create your form:

    php bin/console make:form
    

    To see all make commands you can use, run php bin/console list make