Form_validation.php: required, min_length[], is_unique[] do not work #2143

lanort opened this Issue Jan 9, 2013 · 2 comments


None yet

3 participants


If I set the rule in the controller, everything works as expected:

$this->form_validation->set_rules('name', 'Name', 'required|is_unique[]');
$this->form_validation->set_rules('email', 'E-Mail', 'valid_email');
$this->form_validation->set_rules('zip', 'ZIP', 'callback_validate_zip');
if ($this->form_validation->run() === FALSE){

WITH application/config/form_validation.php
If I use the application/config/form_validation.php file many functions do not work (in this example only the custom callback function and the valid_email work):
File: Controller: operator, function: add

if ($this->form_validation->run() === FALSE){

File: application/config/form_validation.php

<?php $config = array(
  'operator/add' => array(
    array('field'   => 'name',  'label' => 'Name', 'rules'  => 'trim|required|is_unique[]'),
    array('field'   => 'email', 'label' => 'E-Mail',    'rules' => 'trim|valid_email'),
    array('field'   => 'zip',   'label' => 'ZIP',   'rules' => 'trim|callback_check_validate_zip'),

Related to #1933 -- the loading of config rules based on URI, not the individual rules themselves not working.

@narfbg narfbg added a commit that closed this issue Jan 7, 2014
@narfbg narfbg Fix #2143
When trying to load rules from a configuration file, the Form validation library matched against
ruri_string() as opposed to 'controller/method' like described in the manual. Since ruri_string()
also makes sense, now both are being checked with ruri_string() having a higher precedence.

Supersedes PR #2224
@narfbg narfbg closed this in 3b2803e Jan 7, 2014

[is_unique] It Will Work. When We Will Change it :-
$autoload['libraries'] = array('database');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment