Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Form-Validation in multidimenisional input-array is always "required" #1850

blegt210 opened this Issue · 2 comments

3 participants


Form-Validation in multidimenisional input-array is always "required"

In a input-form, I used a multidimensional array like:

<input name="links[1][name]" .. />
<input name="links[1][url]" .. />

<input name="links[2][name]" .. />
<input name="links[2][url]" .. />

<input name="links[3][name]" .. />
<input name="links[3][url]" .. />

Validation-Rules are:

$this->form_validation->set_rules('links['.$i.'][name]', 'Link '.$i.' Name', 'trim|min_length[5]|xss_clean');
$this->form_validation->set_rules('links['.$i.'][url]', 'Link '.$i.' URL', 'trim|min_length[10]|valid_url');

where $i is a counter 1, 2, ....

Here Form-Validation always sets an error "Field required" also I haven't set the required-rule. If the input-array has just one element links[1][] Validation works perfect. Adding one or more element links[2][] the fields are all requried.

In file /system/libraries/Form_validation.php in line 488 function _execute() I changed an is_null()-test to an empty()-test. Now it works like expected.

//if ( ! in_array('required', $rules) AND is_null($postdata)) ====>>> changed to:
if ( ! in_array('required', $rules) && empty($postdata))

I'm trying to test this, but did you add a valid_url() method somewhere?
I see no valid_url method anywhere, so it will never validate to true,
strange enough, the language file does have a reference to it.


Fixed here: 2d48b4f

... although as @GDmac already noted - there's currently no valid_url rule.

@narfbg narfbg closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.