-
Notifications
You must be signed in to change notification settings - Fork 87
Updated Form class, bindValues function to set to empty array if no … #216
Conversation
…ata to pass along for baseFieldset
But we need an unit test to cover your scenario. |
…and (base)Fieldset with own InputFilter). Correctly fails on pre-fix code, post-fix code passes.
Created a test case for the scenario. Am tired though, so please check it as well. More another day. |
test/FormTest.php
Outdated
$form->add($baseFieldset); | ||
$form->setHydrator(new ObjectPropertyHydrator()); | ||
|
||
$baseFieldsetInputFilter = new InputFilter(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove all these lines related to the input-filters. (830 - 835)
The result is the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Did indeed not make a difference for patch.
test/FormTest.php
Outdated
$baseFieldset = new Fieldset('base_fieldset'); | ||
$baseFieldset->setUseAsBaseFieldset(true); | ||
|
||
$form = new Form('default_form'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An unit test should be reduced to a minimum. The name for the form is not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
$form = new Form(); | ||
$form->add($baseFieldset); | ||
$form->setHydrator(new ObjectPropertyHydrator()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use $form->setHydrator(new Hydrator\ObjectProperty());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both are imported, and there are examples of each in the test case. #224 resolves the consistency issues, so I'll leave as-is for now.
Updated Form class, bindValues function to set to empty array if no …
Thanks, @rkeet! |
Updated Form class, bindValues function to set to empty array if no data to pass along for baseFieldset
Provide a narrative description of what you are trying to accomplish:
In detail: #215
In short:
Form->bindValues($data, ...)
callsFieldset->bindValues($data, ...)
.Fieldset has the function defined as:
The
$data
var was set with the following line:In the case of no defined
Input
elements, this may cause there to be no key with that name and have the$data
variable benull
. This then causes a fatal error whenForm->bindValues($data, ...)
callsFieldset->bindValues($data, ...)
In respect, I've assumed that no tests need to be modified (they pass btw, though there's 40'ish that don't run because they're for Annotation) as this function was assumed to work with the happy-flow of properly calling the
Fieldset->bindValues()
function. This change just catches a bug but does not modify the intended functionality (I think).