Welcome Guest, Not a member yet? Register   Sign In
Form validation in 4.1.6 raises type error
#1

(This post was last modified: 01-05-2022, 06:43 AM by sjender.)

Hi,
I used the form validation library to validate a form containing arrays.
Code:
<form>
<input type='text' name='date'>
<input type='text' name='invoice_rule[1]'>
<input type='text' name='invoice_rule[2]'>
......
<input type='submit'>
</form>
I had the following validation rule:
PHP Code:
'invoice_rule' =>  ['rules' =>    'numeric''errors' =>    ['numeric' => 'Not numeric']] 
This worked fine and walked through all the invoice rules.
But now it raises an error "Argument 1 passed to CodeIgniter\Validation\FormatRules::numeric() must be of the type string or null, array given".
I looked at the changelog and indeed, this is one of the changes...
But how am I supposed to validate each element of the array?
I don't want to foreach it, because it makes the code less readable.

Never mind.... already found it.
Typing this message took me longer than reading the manual. LOL.
invoice_rule.* did the trick!
Reply
#2

Thank you for the feedback!
I will add it to Upgrading from 4.1.5 to 4.1.6.
Reply
#3

Added the instruction:
https://codeigniter4.github.io/CodeIgnit...lt-changes
Reply




Theme © iAndrew 2016 - Forum software by © MyBB