在这个表中我想在"响应"字段中显示"是"或"否"而不是"1"和""这是图片显示我的表: 这张图显示了我的表:
我正在使用symfony2.8,在我的实体"typeQuestion"中我有这个:
/**
* @var boolean
* @ORM\Column(name="reponse", type="boolean")
*/
private $reponse;
/**
* Set reponse
*
* @param boolean $reponse
* @return TypeQuestion
*/
public function setReponse($reponse)
{
$this->reponse = $reponse;
return $this;
}
/**
* Get reponse
*
* @return boolean
*/
public function getReponse()
{
return $this->reponse;
}
public function __toString() {
return $this->libelle;
}
Run Code Online (Sandbox Code Playgroud)
}
我有以下形式:
->add('reponse', 'choice', array(
'label' => 'Reponse',
'choices' => array("true" => 'Oui', false => 'Non'),
'expanded' => true,
'multiple' => false,
'required' => true
));
}
Run Code Online (Sandbox Code Playgroud)
在我看来,我有这个:
<td class="center">{{TypeQuestion.libelle}}</td>
<td class="center">{{TypeQuestion.description}}</td>
<td class="center">{{TypeQuestion.reponse}}</td>
Run Code Online (Sandbox Code Playgroud)
在phpmyadmin这是我得到的:在phpmyadmin这是我得到的:2
小智 33
这就是我通常做的事情:
{{ someBoolean ? 'Yes' : 'No' }}
Run Code Online (Sandbox Code Playgroud)
参考:http://twig.sensiolabs.org/doc/templates.html#other-operators