![]() |
validation_errors() returning an empty string after upgrading to 2.1.0 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: validation_errors() returning an empty string after upgrading to 2.1.0 (/showthread.php?tid=49437) |
validation_errors() returning an empty string after upgrading to 2.1.0 - El Forum - 02-19-2012 [eluser]mcryan[/eluser] I've tried this on 2 instances of CI 2.1.0, one downloaded from the website, the other pulled from the stable branch on GitHub, both return an empty string when form validation fails. Initially I noticed this on my own forms, then used the form validation example in the user guides and the outcome is the smae: <?php echo validation_errors(); ?> does not output anything. I have tried this on PHP 5.2 and 5.3 on different servers, but the same problem is happening. Any advice? validation_errors() returning an empty string after upgrading to 2.1.0 - El Forum - 02-19-2012 [eluser]skunkbad[/eluser] [quote author="mcryan" date="1329694016"]I've tried this on 2 instances of CI 2.1.0, one downloaded from the website, the other pulled from the stable branch on GitHub, both return an empty string when form validation fails. Initially I noticed this on my own forms, then used the form validation example in the user guides and the outcome is the smae: <?php echo validation_errors(); ?> does not output anything. I have tried this on PHP 5.2 and 5.3 on different servers, but the same problem is happening. Any advice?[/quote] I am using it just fine. There must be something else wrong in your code. Maybe shoe some code so we can see whats wrong. validation_errors() returning an empty string after upgrading to 2.1.0 - El Forum - 02-20-2012 [eluser]mcryan[/eluser] I started from a clean installation of CI 2.1.0 created a new controller and views and it worked fine. I think one of my config files or something else in the application directory must be broken. I used identical code on the new instance that worked and the existing instance and it failed again, so it has to be that. I'll update here once I crack this one. Will give it another go later on. validation_errors() returning an empty string after upgrading to 2.1.0 - El Forum - 02-20-2012 [eluser]mcryan[/eluser] The problem was that I was extending form_helper.php and had to make a few changes in my version of form_helper in order to line up with the changes in 2.1.0. Glad I finally sorted this one out! validation_errors() returning an empty string after upgrading to 2.1.0 - El Forum - 02-22-2012 [eluser]ToddyBoy[/eluser] I was hoping this would solve my problem as well, but it didn't. I'm getting the validation errors appearing in my view before the validation is being called. Here's my controller: Code: <?php defined('BASEPATH') OR exit('No direct script access allowed'); Here's my view: Code: <!DOCTYPE HTML> Here's the rendered html when the page loads with the error messages appearing: Code: <!DOCTYPE HTML> I've used this code on another installation and it works fine. The other installation I KNOW is 2.1.0. This current installation I THINK is 2.0.2. I downloaded a 2.1.0 installation from github and copied the form_validation helper from 2.1.0 into the not working version and I didn't get anything rendered at all. So I backed out that change and am back to square one. When I actually go through the form and enter a username, for example, and click submit, I only get the error for the password being required. Entering data into both fields, I get the successful validation message. validation_errors() returning an empty string after upgrading to 2.1.0 - El Forum - 02-22-2012 [eluser]mcryan[/eluser] You can't just use a single 2.1.0 file with a 2.0.2 installation. Follow the upgrade instructions. Essentially you replace your entire system folder and you'll have to add a few config files. The only reason I was having a problem is because I extended a helper and needed to make some changes in there. Besides that, I don't really understand what problem you are actually having. Quote:When I actually go through the form and enter a username, for example, and click submit, I only get the error for the password being required. Entering data into both fields, I get the successful validation message. This sounds perfect, what's the problem? validation_errors() returning an empty string after upgrading to 2.1.0 - El Forum - 02-22-2012 [eluser]InsiteFX[/eluser] Because you are assigning the validation errors to a variable! Code: // in view should be validation_errors() returning an empty string after upgrading to 2.1.0 - El Forum - 02-24-2012 [eluser]Chathuranga Tennakoon[/eluser] Hello ToddyBoy i also believe that you cannot assign the error message values for the variables. therefore the below line is not required in your controller. Code: $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); just remove that line and put Code: <?php echo validation_errors(); ?> |