From 978c6b00ff1a976b60e7334be7d869fa26cbd148 Mon Sep 17 00:00:00 2001 From: Bertrand Gauthier <bertrand.gauthier@unicaen.fr> Date: Tue, 10 Jun 2014 12:43:39 +0000 Subject: [PATCH] =?UTF-8?q?AJout=20possibilit=C3=A9=20de=20sp=C3=A9cifier?= =?UTF-8?q?=20la=20route=20vers=20laquelle=20l'utilisateur=20est=20redirig?= =?UTF-8?q?=C3=A9=20une=20fois=20le=20profil=20courant=20s=C3=A9lectionn?= =?UTF-8?q?=C3=A9.=20La=20route=20par=20d=C3=A9faut=20est=20'home'=20(accu?= =?UTF-8?q?eil=20de=20l'appli).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/Helper/UserProfileSelect.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/UnicaenAuth/View/Helper/UserProfileSelect.php b/src/UnicaenAuth/View/Helper/UserProfileSelect.php index 4d015cc..54f3528 100644 --- a/src/UnicaenAuth/View/Helper/UserProfileSelect.php +++ b/src/UnicaenAuth/View/Helper/UserProfileSelect.php @@ -26,6 +26,11 @@ class UserProfileSelect extends UserAbstract */ protected $asSelect = false; + /** + * @var string + */ + protected $redirectRoute; + /** * Retourne le code HTML généré par cette aide de vue. * @@ -75,14 +80,16 @@ class UserProfileSelect extends UserAbstract $html .= $this->getView()->form()->closeTag(); $url = $this->getView()->url('utilisateur/default', array('action' => 'selectionner-profil')); - + $redirectUrl = $this->getView()->url($this->redirectRoute ?: 'home'); + $html .= <<<EOS <script> $(function() { $("input.$inputClass") .change(function() { $("body *").css('cursor', 'wait'); - $.post("$url", $(".$formClass").serializeArray(), function() { location.reload(); }); }) + $.post("$url", $(".$formClass").serializeArray(), function() { $(location).attr('href', "$redirectUrl"); }); + }) .tooltip({ delay: 500, placement: 'left' }); }); </script> @@ -164,4 +171,10 @@ EOS; $this->asSelect = $asSelect; return $this; } + + public function setRedirectRoute($redirectRoute) + { + $this->redirectRoute = $redirectRoute; + return $this; + } } \ No newline at end of file -- GitLab