Closed rkeet closed 5 years ago
@rkeet
first checks if the key exists
Then use the right function for that.
+1
Usually "just used" isset
, now a quick comparison between the 2 does make array_key_exists
come out on top.
Wondering if just a simpler Definitely wrong.isset($data) ? $data : []
would actually suffice for the scenario. Thinking it would.
btw, working on a quick unit test to cover scenario.
I have a Form with a Fieldset, an InputFilter for both. The Fieldset is a
baseFieldset
.The Fieldset contains no mapped
Input
elements, it just has a submit button.During execution of binding data on the fieldset it comes across line 365 of the Form class.
If you have no mapped Elements, the data is empty. It's just a submit action. That means that when binding line 364 sets
$data
to benull
.Function declaration of
Fieldset->bindValues(...)
:If the first argument is
null
(because line 364), then this causes a fatal error.Updating line 364 to the following fixes the problem: first checks if the key exists, if yes continues as it did, else sets
$data
as an empty array.