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

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

I used the form validation library to validate a form containing arrays.
<input type='text' name='date'>
<input type='text' name='invoice_rule[1]'>
<input type='text' name='invoice_rule[2]'>
<input type='submit'>
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!

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

Added the instruction:

Theme © iAndrew 2016 - Forum software by © MyBB