开发者

Zend remove anchor text in url redirect

开发者 https://www.devze.com 2023-01-04 03:11 出处:网络
I have a form that is using an anchor name as it\'s action so that when the form is submitted it is it goes straight back to the form (for example \'www.domain.com/page#contact-form). The idea is if t

I have a form that is using an anchor name as it's action so that when the form is submitted it is it goes straight back to the form (for example 'www.domain.com/page#contact-form). The idea is if there are any errors then it'll go straight to the form (that's near the bottom of the page) so you can see the errors and continue filling in the form. If the form is valid, I want it to redirect to another page (for example www.domain.com/another-page). The problem is that the redirect url still has the anchor text in the url (in the above example it is www.domain.com/another-page#contact-form).

I am using

$this->_helper->redirector->goToRouteAndExit(array(), 'another-page', true);

to goto the another-page route. I have tried setting the url specifically but that doesn't fix it either.

How do I red开发者_JAVA技巧irect to another page and remove that anchor text from the url?


I would have presumed that you could do something like:

if ($this->_request->isPost()) {
   if ($formObject->isValid($this->_request->getPost())) {
      // do something
      $this->_redirect('/my/new/url/');
   } else { // if error
      // do something else
      $this->_redirect('/my/original/url/#anchor);
   }
}

Any use?

Edit: Assuming that you are using Zend_Form/Zend_Dojo_Form

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号