Validation Custom Error Message Clarification |
[eluser]escape[/eluser]
I've got form validation working with the following abbreviated code from my controller: Code: $rules['username'] = "required|min_length[4]|max_length[12]"; If the user passes the validation rules but fails to login correctly I wish to set a custom validation message and display it to the user (separate from the username & password fields). However I'm not at all clear on how to proceed using the $this->validation->set_message function. In my view I'm assuming I may need something like: Code: <?php echo $this->validation->invalidLogin_error; ?> I've looked through many of the validation posts here but I'm still missing some key concept. BTW: I've seen suggestions to use $data[] as an alternate approache but I somehow feel this can be accomplished with validaton. Any guidance would be appreciated. Thanks Chris
[eluser]OES[/eluser]
I would suggest using Flash Data. IE example of my validation on a working site. I keep my validation within a seperate function but you can easy keep it withing the same function and not do a redirect. Code: rules = array( // Your rules ); Then in my controller I collect any flash data and pass it to the view ie. Code: $this->data['success'] = $this->session->flashdata('success'); I can then repopulate my form and display errors/success etc. See userguide: http://ellislab.com/codeigniter/user-gui...sions.html Hope this helps. Lee |
Welcome Guest, Not a member yet? Register Sign In |