Question

How can I generate link to another module in Symfony admin generator Yaml? I am trying to link from sfGuardUser module (user list) to profile/viewProfilesDetails but it always points to sfGuardUser/viewProfilesDetails

My generator.yml :

(...)
  list:
    title:   Użytkownicy
    display: [=username, _name, created_at, last_login]
    actions: {}
    batch_actions: {}
    object_actions:
      _edit: ~
      signIn:
        label:  Zaloguj jako
        action: signIn
      viewProfiles:
        label:  Profile
        module: profiles
        action: viewProfilesDetails
(...)
Was it helpful?

Solution

I don't think you can specify a module in this configuration, but only an action from the same module.

I personnaly do this in this way.

generator.yml :

object_actions:
  _edit: ~
  _delete: ~
  viewItems: { label: View items, action: viewItems }

Then in the same module for the generator.yml, I create an action:

public function executeViewItems($request)
{
  $this->redirect($this->generateUrl('items'));
}

It generates a link called View items, like /blog/158/viewItems which redirect to the /items (which is the route @items).

Edit:

In fact, you can't specify an other module.

The template _list_td_actions.php display list.object_actions. Here is the interesting part:

<?php else: ?>
    <li class="sf_admin_action_<?php echo $params['class_suffix'] ?>">
      <?php echo $this->addCredentialCondition($this->getLinkToAction($name, $params, true), $params) ?>
    </li>
<?php endif; ?>

It calls the getLinkToAction which use the current module by using $this->getModuleName():

return '[?php echo link_to(
  __(\''.$params['label'].'\', array(), \''.$this->getI18nCatalogue().'\'), 
  \''.$this->getModuleName().'/'.$action.$url_params.', 
  '.$this->asPhp($params['params']).'
) ?]';
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top