0

I'm using Twitter Bootstrap in Symfony 1 application. I've a tabbed navigation but I want to get redirected to the same tab I was after perform a add action. See this image as you may see I in Emisores tab, I want after perform a Add action (is "Crear Nuevo") I got redirected to the same tab. For redirection I use this:

$this->redirect('admin/index');

Is that possible? How?

4

1 回答 1

2

在您的控制器中

// \apps\myApp\modules\profile\actions\actions.class.php
public function executeUpdate()
{
    // Handle form submit and update

    $this->getUser()->setFlash('activeTab', 'profile');
    $this->redirect('admin/index');
}

现在在您的模板中,您可以知道上次激活的选项卡是什么,因为您在执行重定向之前将其名称存储在 flash 对象中。因此,检索 flash 值以确定要在模板中激活哪个选项卡,如下所示:

// \apps\myApp\modules\admin\templates\indexSuccess.php
<script>
     <?php 
     // Would be better if assigned this in your controller and passed it to the template
     $activeTab = $sf_user->getFlash('activeTab', 'default_tab_id');
     ?>
     $('#myTab a[href="#<?php echo $activeTab ?>"]').tab('show');
</script>
于 2013-06-11T13:42:38.543 回答