开发者

Add a "boolean" column to Symfony's generated admin

I have a blog made with symfony 1.4. In the generated admin, I've added the column "has tags", by adding the following to Content.class.php :

开发者_如何学编程
public function getHasTags()
{
  $count = Doctrine_Core::getTable('Tagging')
    ->createQuery('c')
    ->where('c.taggable_model = "Content"')
    ->andwhere('c.taggable_id = ?', $this->getId())
    ->count();

  if ($count > 0) 
    return true;
  else
    return false;
}

This works, but the column only shows "1" for true and nothing for false. Can I set this new column as boolean, so that symfony will show the picture of a cross or a check mark ?

Add a "boolean" column to Symfony's generated admin


in your generator.yml

fields:
  yourFieldName:
    label: Has link
    type: Boolean
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜