【问题标题】:What are the steps used in symfony constraint validationsymfony约束验证使用的步骤是什么
【发布时间】:2013-11-15 03:56:33
【问题描述】:

我在读这个

http://symfony.com/doc/current/reference/constraints/NotNull.html

// src/Acme/BlogBundle/Entity/Author.php
namespace Acme\BlogBundle\Entity;

use Symfony\Component\Validator\Constraints as Assert;

class Author
{
    /**
     * @Assert\NotNull()
     */
    protected $firstName;
}

现在我想知道,当我提交form 时,我的firstnamenull

我尝试保存它。然后按哪个顺序执行验证。我是说

  1. 我的意思是当 symfony 读取非空注释时以及它是如何读取它的
  2. 用于检查的具体步骤/文件

【问题讨论】:

    标签: php validation symfony


    【解决方案1】:

    formBuilder 将根据可为空的字段属性和字段类型(或者如果您指定 required => false)处理 html5 验证。

    $form->isValid() 将检查所有类约束和/或作为参数传递给 formBuilder 的特定规则

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-11
      • 1970-01-01
      • 2012-11-13
      • 2012-08-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多