【问题标题】:Custom render in generated admin with Symfony使用 Symfony 在生成的管理员中自定义渲染
【发布时间】:2011-12-14 03:59:09
【问题描述】:

所以,这是我的小问题:我已经使用 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:     ~

如您所见,在列表/显示中,我有一个 cv_file,它给了我一个链接(来自数据库)。我需要使用链接呈现此列。

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

非常感谢!

【问题讨论】:

    标签: php symfony1 admin-generator


    【解决方案1】:

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

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多