symfony 管理生成器中的 link_to 错误
我做了两个列表操作。一个实际上对应于默认的 _new 操作,另一个略有不同。因此,在生成器.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>
I made two List actions. One actually corresponds to the default _new action and other is slightly different. So in generator.yml, I put:
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"
Now in my list view, I can see two links for these two actions but the create Link links to
/poster/ListCreate/action instead of /poster/ListCreate. What can be a reason for that? I'm also pasting the _list_actions.php file in the cache.
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加自定义操作:
您必须编写路由规则才能获得您正在寻找的行为:
Adding a custom action:
you have to write a routing rule to have the behavior you are looking for: