I have a project setup with Symfony and Sonata for the admin section... but my current problem is that I want to give the option to import a list of Names from a file (preferably a txt file) like this:
Name1
Name2
...
NameN
I want to upload the file and create all the clients with those Names in the file. So basically, I need to upload the file, read it to create the Client objects based on this:
CLIENT ENTITY
-ID (autogenerated)
-NAME
so, these will be saved to the DB using the Entity Manager and then dispose the file (there is no need to keep the file saved).
I have tried following this example: https://symfony.com/doc/current/controller/upload_file.html But so far, no luck.
Even tried this one: https://symfony.com/doc/master/bundles/SonataAdminBundle/cookbook/recipe_custom_action.html I thought that "8.2. Custom Action without Entity" could help me in this case, but couldn't figure out how to adapt it to my needs.
I cannot believe nobody else tried to import from a file something on the Sonata admin bundle...
Thanks!