For a project I need to check if all form's fields are present in a PUT
request.
Simple data validation with the NotNull
/ NotBlank
constraints is not appropriate because the fields in the request can be set with NULL
or blank values but they have to be present.
My idea is to take all names from a Form's field and check if those fields are present in the request array.
To do the trick I need to get names of those fields, there's an array in the Form class named orderedKeys
which contains exactly what I want, but the variable is set to private
.
Is there any other way to get access to those keys ?
You can get all the child forms of a form by doing
$form->all();
Then you can recover the name of each field by doing
$child->getName();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With