09-25-2018, 01:55 PM
I've set up form validation for (amongst other fields) a text input box with the name "cms", this is in my application\config\form_validation.php file:
// ...
array(
'field' => 'cms',
'label' => 'CMS',
'rules' => 'is_natural_no_zero'
),
// ...
If I use a regular <input name="cms" value="value"> this works fine.
Yet, if I tweak the html for the form, and send a "cms" array to the controller instead of a string value, like this
<input name="cms[]" value="some"><input name="cms[]" value="other">
this array passes the validation rule! Which is not what I want, nor what I expected.
I would expect (and want) the form validation to fail if an array instead of a string value was submitted.
Is there a way to enforce this in CodeIgniter (using validation rules)?
// ...
array(
'field' => 'cms',
'label' => 'CMS',
'rules' => 'is_natural_no_zero'
),
// ...
If I use a regular <input name="cms" value="value"> this works fine.
Yet, if I tweak the html for the form, and send a "cms" array to the controller instead of a string value, like this
<input name="cms[]" value="some"><input name="cms[]" value="other">
this array passes the validation rule! Which is not what I want, nor what I expected.
I would expect (and want) the form validation to fail if an array instead of a string value was submitted.
Is there a way to enforce this in CodeIgniter (using validation rules)?