2011-12-07 42 views
2

我做了兩個List操作。其中一個實際上對應於默認的_new動作,其他則略有不同。因此,在generator.yml,我把:symfony管理生成器中的link_to錯誤

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" 
在我的列表視圖

現在,我可以看到兩個鏈接,這兩個動作,但創建鏈接鏈接 /海報/ ListCreate /動作代替/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> 

回答

2

添加自定義操作:

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

你必須寫一個路由規則有你要找的行爲:

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

感謝。該規則必須高於sfDoctrineRouteCollection。 – prongs

+0

不客氣。我忘了寫我使用'Propel',所以如果有差異,規則必須翻譯爲'Doctrine'。 – macgyver

+1

..是的,規則必須寫在模塊的一般規則之上,因爲路由規則是從頂部到底部讀取的。 – macgyver

相關問題