开发者

Displaying confirmation page before submitting a form

开发者 https://www.devze.com 2023-01-11 19:16 出处:网络
Wi开发者_StackOverflow社区thin a Cake application, if a user is submitting a form to edit a record, what do you think would be the best way to outline the specific changes made? I would like to displa

Wi开发者_StackOverflow社区thin a Cake application, if a user is submitting a form to edit a record, what do you think would be the best way to outline the specific changes made? I would like to display the values to all of the fields that the user is changing and offer them the option to either confirm the changes or go back and change them. I assume that it will involve comparing the submitted data with the existing record, but I was hoping Cake had some built in functionality to do this. Any thoughts? I'm also open to any javascript solutions as well, but I'd like to have a Cake fallback for those users who still operate in the stone age.


This seems like an outdated process, to verify input. I can see doing this for a billing screen, but not necessarily every time a user wants to edit a record. It's like we are calling into question their quality and saying, "Are you sure you entered everything correctly?" I think this is poor design and should be avoided. They will know if they made a mistake. They can just as easily go back and make the change again if necessary.

I would suggest providing simple form validation (making sure email addresses are actually email addresses, checking phone numbers, etc.). Beyond that, it would be up to the user to enter correct information. It can get annoying being constantly asked, "ARE YOU SURE?"

That being said, one way to do this (if you MUST) is to modify your default method. So for example, if you are using the function called update() in your information controller, you could write something like this:

function update() {
   if($this->data) {
      if($this->data['Information']['confirmed']) {
         // save updated information
      } else {
         // display changes to be made (use hidden fields and add confirmed=1)
      }      
   }
   // display edit form
}

I am of the opinion it is bet to keep the functionality all within the same method if possible. It prevents code from spreading out all over the place and becoming unmanageable.

Good luck!


Best way is to create a filed in the database and set it to 0 by default or on first fill and to 1 once he confirms it

0

精彩评论

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

关注公众号