使用Symfony在生成的管理中自定义渲染

时间:2011-10-24 13:48:02

标签: php symfony1 admin-generator

所以,这是我的小问题:我已经使用Symfony管理生成器生成了一个管理员,但是我需要显示一个链接(或者一个按钮),可以单击打开C.V.文件。

截至目前,我有:

generator:
  class: sfDoctrineGenerator
  param:
    model_class:           Client
    theme:                 admin
    non_verbose_templates: true
    with_show:             false
    singular:              ~
    plural:                ~
    route_prefix:          client
    with_doctrine_route:   true
    actions_base_class:    sfActions

    config:
      actions: ~
      fields:
         job_titles_list: { label: Emplois disponnibles }
         created_at:      { label: Cree le }
         updated_at:      { label: Mis a jour le }
      list:    
         display: [=name, firstname, experience, connexe, formation, created_at, cv_file]
         title: Gestion des prospects      
      filter: 
         display: [name, firstname, phone, cellphone, postalcode, experience, connexe, formation, job_titles_list, created_at, updated_at]
      form:    ~
      edit:  
         fields:
            formation: { label: Formation }
            experience: { label: Experience }
            connexe: { label: Connexe }
      new:     ~

正如你所看到的,在list / display中,我有一个cv_file,它给了我一个链接(来自数据库)。我需要使用链接呈现此列。

顺便说一句,我对Symfony一无所知,所以要温柔;)

非常感谢!

1 个答案:

答案 0 :(得分:3)

您可以在列表中使用虚拟字段,例如_curriculum:

display: [=name, firstname, experience, connexe, formation, created_at, _curriculum]

因此,Symfony将通过模块的模板文件夹读取部分名为_curriculum.php的部分。 最后,您必须在模板文件夹中创建_curriculum.php并在此部分内写入代码以创建链接标记:

<?php echo link_to('Download CV', $Client->getCvFile()); ?>