I've been having some 'issues' with the admin generator (Propel version). The HTML generation behavior between the list view and the form view is very different, and I'd like to know why, as the form view works better (and as expected) compared to the list view.
I have the following YAML for the 'edit' action,
edit:
actions:
custom: { confirm: 'Run this custom action?' }
_list: ~
_save: ~
This generates the following HTML/PHP for the custom action specified,
// 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 ...
Now, if I add my custom action to the YAML for the list view,
list:
object_actions:
custom: { confirm: 'Run this custom action?' }
_edit: ~
_delete: ~
I get the following HTML generated,
// Snip ...
<li class="sf_admin_action_custom">
<?php echo link_to(__('Custom', array(), 'messages'), 'users/ListCustom?id='.$user->getId(), array()) ?>
</li>
// Snip ...
There's some distinct differences here that I find very odd,
link_to()
function if not. However, the list actions code just uses the link_to()
function, not even trying to use the helper.link_to()
. Why is this? I'm hoping this is a bug.If someone could shed some light as to why the two generate differently, I'd really appreciate it.
Thank you.
The admin generator uses templates that generates the above HTML/PHP. The default theme is located at:
sfConfig::get('sf_symfony_lib_dir')/plugins/sfPropelPlugin/data/generator/sfPropelModule/admin/
. (version 1.2)
or
$sf_symfony_data_dir/generator/sfPropelAdmin/default/
(version 1.0)
The HTML/PHP code differs because the templates used to generate these files are different, but you can modify them to your likings by creating your own theme and specify that in the generator.yml. E.g.:
generator:
class: sfPropelGenerator
param:
model_class: BlogArticle
theme: customTheme
For more information about how to do that, read http://www.symfony-project.org/book/1_2/14-Generators