2009年12月19日星期六

[fw-mvc] Problem with Zend_Controller_Action_Helper_Url::url()

I'm not sure if I'm using this correctly, but when I try to construct a URL
using this helper method, it seems to include all URL parameters sent in the
current request, even if I do not include them in the first argument.

Example:

In my application, I have a form that allows a user to enter their email for
a password reset. On submit, the form makes an AJAX request to a controller
action that handles sending out the reset email. It uses the Ajax Context
switcher with JSON as its format, so "format/json" needs to be included in
the URL for it to work. Within that action, I'm using
Zend_Controller_Action_Helper_Url::url() to build the reset password url.
Here's my code:

// We need to send an email with a link to reset their password
$urlHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Url');
/* @var $urlHelper Zend_Controller_Action_Helper_Url */

// Construct the url to send in the email
$resetPasswordUri = $urlHelper->url(array(
'controller' => 'users',
'action' => 'reset-password',
'username' => $user->username,
'token' => $forgotPasswordToken->token
)

And $resetPasswordUri ends up being
http://www.mydomain.com/users/reset-password/username/USERNAME/token/TOKEN/format/json

I'm not sure why format/json gets tacked on, am I using the helper
incorrectly?

Thanks
--
View this message in context: http://n4.nabble.com/Problem-with-Zend-Controller-Action-Helper-Url-url-tp975540p975540.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: