开发者

saving form data and sessions

I'm currently developing a small app, which is basically a form to capture data.

I'm having a small problem though, with the form validation.

The URLs are in the form of http://www.example.com/123456 or http://www.example.com/234567, so anythin开发者_StackOverflow中文版g with a numeric value.

All this is fine, but because these number do not represent an id of a record in my db, this is a slight problem, because when the form is invalid, the page is redirected to http://www.example.com/

I am needing to keep this numeric value in the URL.

Is this possible?

I've looked at storing the value in a session, but this seems to be cleared everytime the URL changes.

Thanks


well, seems as simple as

if($form->isValid()){
  // do stuff 
} else {
  // invalid, then redirect
  $this->redirect('http://www.example.com/' . $request->getParameter('random_number'))
}

assuming you have a route like

formroute:
  url: /:random_number
  ....
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜