【问题标题】:Error in link_to in symfony admin generatorsymfony 管理生成器中的 link_to 错误
【发布时间】:2012-01-15 06:42:54
【问题描述】:

我做了两个列表动作。一个实际上对应于默认的 _new 操作,而另一个则略有不同。所以在 generator.yml 中,我放了:

  list:    
    max_per_page: 10
    title: All Posters
    display: [approved, name, user_id, _web_path, created_at]
    actions:
      upload : #this is actually equivalent to _new. 
        credentials: create_poster
        label: "Upload Poster"
        action: new
      create : 
        credentials: create_poster
        label: "Create Poster"

现在在我的列表视图中,我可以看到这两个操作的两个链接,但创建链接链接到 /poster/ListCreate/action 而不是 /poster/ListCreate。这可能是什么原因?我还将 _list_actions.php 文件粘贴到缓存中。

<li class="sf_admin_action_upload">
<?php if ($sf_user->hasCredential('create_poster')): ?>
<?php echo link_to(__('Upload Poster', array(), 'messages'), 'poster/new', array()) ?>
<?php endif; ?>

</li>
<li class="sf_admin_action_create">
  <?php if ($sf_user->hasCredential('create_poster')): ?>
<?php echo link_to(__('Create Poster', array(), 'messages'), 'poster/create', array()) ?>
<?php endif; ?>

</li>

【问题讨论】:

    标签: php symfony1 symfony-1.4 link-to admin-generator


    【解决方案1】:

    添加自定义操作:

    list:
      actions:    
        myaction: 
          label: "My action"
          action: myaction
    

    您必须编写路由规则才能获得您正在寻找的行为:

    myaction:
      url:   /mymodule/myaction
      param: { module: mymodule, action: myaction }
    

    【讨论】:

    • 谢谢。并且该规则必须高于 sfDoctrineRouteCollection。
    • 不客气。我忘了写我使用Propel,所以如果有差异,必须将规则翻译为Doctrine
    • .. 是的,规则必须写在模块的一般规则之上,因为路由规则是从上到下读取的。
    猜你喜欢
    • 1970-01-01
    • 2011-11-07
    • 1970-01-01
    • 2011-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-26
    • 1970-01-01
    相关资源
    最近更新 更多