我在管理生成器(Propel 版本)上遇到了一些“问题”。列表视图和表单视图之间的 HTML 生成行为非常不同,我想知道为什么,因为与列表视图相比,表单视图工作得更好(并且符合预期)。
我有以下 YAML 用于“编辑”操作,
edit:
actions:
custom: { confirm: 'Run this custom action?' }
_list: ~
_save: ~
这将为指定的自定义操作生成以下 HTML/PHP,
// Snip ...
<li class="sf_admin_action_custom">
<?php if (method_exists($helper, 'linkToCustom')): ?>
<?php echo $helper->linkToCustom($form->getObject(), array( 'confirm' => 'Run this custom action?', 'params' => array( ), 'class_suffix' => 'custom', 'label' => 'Custom',)) ?>
<?php else: ?>
<?php echo link_to(__('Custom', array(), 'messages'), 'users/ListCustom?id='.$user->getId(), array()) ?>
<?php endif; ?>
</li>
// Snip ...
现在,如果我将自定义操作添加到列表视图的 YAML,
list:
object_actions:
custom: { confirm: 'Run this custom action?' }
_edit: ~
_delete: ~
我得到以下 HTML 生成,
// Snip ...
<li class="sf_admin_action_custom">
<?php echo link_to(__('Custom', array(), 'messages'), 'users/ListCustom?id='.$user->getId(), array()) ?>
</li>
// Snip ...
这里有一些明显的差异,我觉得很奇怪,
- 表单操作代码检查帮助器上是否有方法,如果有则使用它,如果没有则回退到标准
link_to()
函数。但是,列表操作代码仅使用该link_to()
函数,甚至没有尝试使用帮助程序。 - 表单操作代码将我的自定义确认消息传递给自定义帮助方法,但模板都没有将它传递给
link_to()
. 为什么是这样?我希望这是一个错误。
如果有人可以阐明为什么两者产生不同的原因,我将非常感激。
谢谢你。