duankan6894 2018-05-25 11:43
浏览 40
已采纳

Sylius定制模型与图像

I followed those recipes to:

  1. Create a custom model
  2. Add images to this custom model

I detected some things that don't happens like the recipes say, but once I have my custom model working, with the forms, the grid, the validation, the form extended to allow upload images... I got this error after send the form of creating a new object:

An exception occurred while executing 'INSERT INTO app_designer_image (type, path, owner_id) VALUES (?, ?, ?)' with params ["avatar", null, 2]:

I can't find the way to upload an image. Following the recipe, I defined a Image Upload Service listener, listening to the sylius.designer.pre_create and sylius.designer.pre_update but those events are never triggered, and when the image is going to be persisted, always fail because the path is not defined...

Any clue of what can be happening?

  • 写回答

1条回答 默认 最新

  • dsw1608 2018-05-29 13:39
    关注

    OK, I found the problem. There was a misconfiguration for the event listener, I attach the listener to the wrong event.

    My mistake was follow strictly all the steps in this recipe. The problem is that the recipe is based on an extended version of an existing model, and the name of the events for a custom model is prepended by app. instead of sylius..

    So, the event in the example is sylius.shipping_method.pre_create and mine is not sylius.designer.pre_create but app.designer.pre_create.

    Once I fixed this everything starts to work as expected.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题