diff --git a/src/UnicaenAuth/View/Helper/UserProfileSelect.php b/src/UnicaenAuth/View/Helper/UserProfileSelect.php index 4d015cc746795cd70b84629a9269c150da309b98..54f35283b98c520a68b6d57b66baf447a6ef96d2 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