Form validation with redirect |
10-27-2015, 10:29 AM
(This post was last modified: 10-27-2015, 10:41 AM by joseph.dicdican. Edit Reason: added images for example ) (10-27-2015, 03:42 AM)Narf Wrote: Redirecting is never the solution ... every single time I see a thread with a title similar to this one, I know the OP is doing something wrong. I agree to what Narf said here. I just knew flashdata just this day not deeply. I still don't know yet when to use this feature. It is not a best solution to redirect when implementing notifications/error message reporting. Regarding the main topic, I would just like to share my usual way on implementing error messages. (e.g. notifications) First I always have a private property called $data (array)in my controller. (e.g. private $data = array()) Then, I some codes like below, Controller part, PHP Code: // intended for errors, titles etc. View part, Code: <?php if($hasError) { // check if has error ?> For the javascript part to have an autoscroll feature, but I suggest to make use of jquery library to have convenient javascript codings. Code: <script type="text/javascript"> You can also refer to this link to see more of auto scroll using javascript. Please see attachment for my local example. I hope this can help. Thank you. -joseph.dicdican ![]()
Joseph K. Dicdican
Softshore Global Solutions Inc. | Junior Web Developer Intern Passerelles numériques Philippines | Scholar [email protected] |
Welcome Guest, Not a member yet? Register Sign In |