Welcome Guest, Not a member yet? Register   Sign In
Form Validation Issue
#1
Wink 
(This post was last modified: 10-03-2016, 05:41 PM by krishg.)

Migrating from CI 2.x to 3.0. This form validation issue is tripping me. Here is what I have i

Code:
if(!isset($_POST['event_create'])){
            $this->form_validation->set_rules('url', 'URL', 'required|alpha_dash');
            $this->form_validation->set_rules('dateStart', 'Event Date', 'required|regex_match[/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/]');
            $this->form_validation->set_rules('timeStart', 'Event Start Time', 'required|regex_match[/^(?=\d)(?:(?!(?:1582(?:\.|-|\/)10(?:\.|-|\/)(?:0?[5-9]|1[0-4]))|(?:1752(?:\.|-|\/)0?9(?:\.|-|\/)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\.|-|\/)(?:29|30))))(\d{4})([-\/.])(0?\d|1[012])\2((?!00)[012]?\d|3[01])(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]\d|2[0-3])(?::[0-5]\d){1,2})?$/]');
            $this->form_validation->set_rules('timeEnd', 'Event End Time', 'regex_match[/^(?=\d)(?:(?!(?:1582(?:\.|-|\/)10(?:\.|-|\/)(?:0?[5-9]|1[0-4]))|(?:1752(?:\.|-|\/)0?9(?:\.|-|\/)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\.|-|\/)(?:29|30))))(\d{4})([-\/.])(0?\d|1[012])\2((?!00)[012]?\d|3[01])(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]\d|2[0-3])(?::[0-5]\d){1,2})?$/]');
            $this->form_validation->set_rules('email', 'Email', 'valid_email');
}
The error message I get is 
Unable to access an error message corresponding to your field name Event Start Time.(regex_match[/^(?=\d)(?Sad?!(?:1582(?:\.)
Unable to access an error message corresponding to your field name Event End Time.(regex_match[/^(?=\d)(?Sad?!(?:1582(?:\.)
Worked fine with CI 2.1. 
xss filter flag is set to true. I have checked that we are not using xss_clean in form_validation->set_rules.

Code:
$config['global_xss_filtering'] = TRUE;

I added $autoload['helper'] = array('security') so, my autoload.php for helpers looks like this


Code:
$autoload['helper'] = array('form', 'url', 'utility' );
$autoload['helper'] = array('security');


This change prevented the error message from displaying on form validation, but resulted in new errors

Severity: Error
Message: Call to undefined function url_title()
Filename: controllers/Events.php
Line Number: 756
Fatal error: Call to undefined function base_url() in /var/www/html/application/views/errors/html/error_php.php on line 10

edit: Looking at the logs I found this 
Code:
INFO - 2016-10-03 17:31:40 --> Language file loaded: language/english/form_validation_lang.php
DEBUG - 2016-10-03 17:31:40 --> Unable to find validation rule: regex_match[/^(?=\d)(?:(?!(?:1582(?:\.
ERROR - 2016-10-03 17:31:40 --> Could not find the language line "form_validation_regex_match[/^(?=\d)(?:(?!(?:1582(?:\."
DEBUG - 2016-10-03 17:31:40 --> Unable to find validation rule: regex_match[/^(?=\d)(?:(?!(?:1582(?:\.
ERROR - 2016-10-03 17:31:40 --> Could not find the language line "form_validation_regex_match[/^(?=\d)(?:(?!(?:1582(?:\."

I went ahead and added this to system\language\english\form_validation_lang.php

$lang['form_validation_regex_match'] = 'The {field} must be a valid time';

No change. 

Curious thing is that the error message in the log is not displaying the complete regex pattern

Any ideas?
Reply


Messages In This Thread
Form Validation Issue - by krishg - 10-03-2016, 02:30 PM
RE: Form Validation Issue - by InsiteFX - 10-03-2016, 06:14 PM
RE: Form Validation Issue - by krishg - 10-03-2016, 06:38 PM
RE: Form Validation Issue - by krishg - 10-03-2016, 09:24 PM
RE: Form Validation Issue - by krishg - 10-03-2016, 09:44 PM
RE: Form Validation Issue - by InsiteFX - 10-04-2016, 02:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB