dsieyx2015 2015-10-23 13:47
浏览 6
已采纳

在Sonata Admin中出现故障时,可以获得更详细的消息

I am curious about the way in which Sonata Admin handle and displays error messages as I need them to be a little more descriptive. For instance when the message comes from DB because a constraint fails I got a message like this:

An error has occurred during update of item "Media Title Test".

But if I leave a required field empty the error is the same. I want to know if it's possible to handle this in some way in order to be more descriptive. Any advice or help?

  • 写回答

1条回答 默认 最新

  • duanhuizhe6767 2015-10-23 14:22
    关注

    You can pass validation rules and message using Constraint in your entity.

    // src/AppBundle/Entity/Author.php
    
    // ...
    use Symfony\Component\Validator\Constraints as Assert;
    
    class Author
    {
        /**
         * @Assert\Choice(
         *     choices = { "male", "female", "other" },
         *     message = "Choose a valid gender."
         * )
         */
        public $gender;
    
        // ...
    }
    

    Validation Constraints Reference will give you a full list of constraint available by default in Symfony.

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

报告相同问题?

悬赏问题

  • ¥15 锅炉建模+优化算法,遗传算法优化锅炉燃烧模型,ls-svm会搞,后面的智能算法不会
  • ¥20 MATLAB多目标优化问题求解
  • ¥15 windows2003服务器按你VPN教程设置后,本地win10如何连接?
  • ¥15 求一阶微分方程的幂级数
  • ¥15 关于#线性回归#的问题:【统计】回归系数要转化为相关系数才能进行Fisher' Z转化吗(相关搜索:回归模型)
  • ¥100 使用matlab解决含分段变量的优化问题
  • ¥15 matlab基于鲸鱼算法优化vmd
  • ¥20 PCB设计与制作问答
  • ¥20 课堂跑如何下载ppt
  • ¥15 STM32阿里云平台显示不了传感器采集的数据