duano3557 2016-10-19 10:51
浏览 29
已采纳

具有多个条件的语句[symfony2]

I have an entity named verified in my table user. I would like if verified is null to show this [you can upload your application], if verified =2 to show this [your application is in process], if verified =3 your application has been verified.

but for now if verified =3 is showing the message of verified =2.

This is what i have done:

 {% 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;
}
  • 写回答

1条回答 默认 最新

  • dongshuql24533 2016-10-19 10:57
    关注

    You don't need to use the length filter (the scope of that filter is for count the element of an array, collection etc), so try simple:

    {% 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 %}
    

    And invert the condition.

    Hope this help

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

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大