doushang1964 2018-12-13 13:07
浏览 8

如何从文件导入Sonata Admin上的名称列表

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!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
    • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
    • ¥15 Centos / PETSc / PETGEM
    • ¥15 centos7.9 IPv6端口telnet和端口监控问题
    • ¥120 计算机网络的新校区组网设计
    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 海浪数据 南海地区海况数据,波浪数据
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等