Validation fails
#16057
Replies: 1 comment 3 replies
-
I am pretty sure that arrays are a problem with form data - I have seen in the past people reporting it and have not seen an implementation for this. It is of course in the todo list because many people work with that. As for the |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying v5.0.0RC4 with PHP8.1.
In the class that extends \Phalcon\Forms\Form, we specified validation when defining the element.
I expect it to be a number from 0 to 15, but I want to make an error for other numbers, strings, and unset (null or '').
But with the above configuration, I get this error.
Deprecated: ctype_digit(): Argument of type null will be interpreted as string in the future
This is probably because the specification of ctype_*() has changed since PHP8.1, but Phalcon currently does not support it.
It would allow an unexpected value, but at the moment it's unavoidable, so even if I change it to Validator\Numericality, it won't recognize the posted value.
After trying various things, it seems that there is a problem with the name of the element.
I receive the form data in an array because it takes less time to process it after it is received.
For example:
It is often used in select/option instead of input.
(There are cases where multiple checkboxes are collectively acquired as
name="cb[]"
)So I write the following in form::initialize().
With this, you can get the HTML element with the name with [ ] in the view, but it doesn't seem to understand it during validation.
If you change "order[1]" to "order1", it will be processed without problems, but considering the processing after receiving it, I would like to receive it as an array.
Is it a problem that you can set it and output HTML tags, but you can't validate it?
Beta Was this translation helpful? Give feedback.
All reactions