form validation and checking for allowed values for example in listbox - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: form validation and checking for allowed values for example in listbox (/showthread.php?tid=56175) Pages:
1
2
|
form validation and checking for allowed values for example in listbox - El Forum - 12-02-2012 [eluser]seba22[/eluser] [quote author="CroNiX" date="1354473720"]What do your error logs show? What's the error message? How are you loading the validation library? What is the filename of your new MY_Form_validation.php fileand it's location? How are you setting the rules? You've changed things but aren't showing the rest of the code where you changed them.[/quote] Actually i don't have any error log! Just ISE (white page - http header internal server error 500) So starting from begining, i have controller Code: class Admin extends CI_Controller { Here i initialize form, and form_validation. Here i use it Code: $allowed = array("a", "aa", "aaa"); When i remove valid_array (entry) validation run OK. Code: /application/libraries/MY_Form_validation.php Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Function is called properly, look at this: When i add mail Code: function valid_array_element($str, $allowed) I entered "invalid string" into form validated field. Email i got: Code: String to test: If You need any tests, please tell me i will provide. form validation and checking for allowed values for example in listbox - El Forum - 12-02-2012 [eluser]CroNiX[/eluser] Show your form element that this rule is being applied on. Something is strange with your mail test. It says "invalid string" where it should be showing the value of the form field. Also remove the last closing php tag - they are unnecessary and can cause problems if whitespace appears after them - so it's best to just not use them. You'll notice none of CI's libraries or anything else have a close php tag. form validation and checking for allowed values for example in listbox - El Forum - 12-02-2012 [eluser]seba22[/eluser] [quote author="CroNiX" date="1354475386"]Show your form element that this rule is being applied on. Something is strange with your mail test. It says "invalid string" where it should be showing the value of the form field.[/quote] Sorry, i just enter this as a string To just express, that string should not pass validation because simple "aaa" actually should pass. Here's part form Code: <input type="text" name="admin_title" value="<?php echo $populate['admin_title']; ?>"> Sorry, for make if confusing Added: I remove close php tag, still ISE error form validation and checking for allowed values for example in listbox - El Forum - 12-21-2012 [eluser]seba22[/eluser] Hello, Finally i got it working. Replace this Code: $this->set_error('valid_array_element', 'The %s field can only be one of the following options: ' . implode(', ', $allowed)); to Code: $this->error('valid_array_element', 'The %s field can only be one of the following options: ' . implode(', ', $allowed)); function name is just "error" not "set_error" Regards ;-) |