我的表verified
中有一个名为user
的实体。我想验证null
是否显示[您可以上传您的申请],如果已经过验证=2
以显示此[您的申请正在处理中],如果已经过验证=3
您的申请已经已经过验证。
但是现在,如果已经过验证=3
正在显示已验证=2.
这就是我所做的:
{% if entity.verified is empty %}
<p>
you can upload your application
</p>
{% elseif entity.verified|length !=2 %}
<p>
your application is in process
</p>
{% elseif entity.verified|length !=3 %}
<p>
your application has been verified
</p>
{% endif %}
user.php的
/**
*
* @ORM\Column(name="verified", type="decimal", options={"default" : 0}, nullable=true)
*/
protected $verified;
/**
* Set verified
*
* @param string $verified
* @return User
*/
public function setVerified($verified)
{
$this->verified = $verified;
return $this;
}
/**
* Get verified
*
* @return string
*/
public function getVerified()
{
return $this->verified;
}
答案 0 :(得分:1)
您不需要使用长度过滤器(该过滤器的范围用于计算数组元素,集合等),所以请尝试简单:
{% if entity.verified is empty %}
<p>you can upload your application</p>
{% elseif entity.verified == 2 %}
<p>your application is in process</p>
{% elseif entity.verified == 3 %}
<p>your application has been verified</p>
{% endif %}
反转条件。
希望这个帮助