-
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
Changes from 4 commits
26fcee5
3b84df4
4e235a6
072894a
a3edaaf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,11 +15,11 @@ | |
use Zend\Form\Factory; | ||
use Zend\Form\Fieldset; | ||
use Zend\Form\Form; | ||
use Zend\Hydrator; | ||
use Zend\Hydrator\ObjectProperty as ObjectPropertyHydrator; | ||
use Zend\InputFilter\BaseInputFilter; | ||
use Zend\InputFilter\InputFilter; | ||
use Zend\InputFilter\Factory as InputFilterFactory; | ||
use Zend\Hydrator; | ||
use Zend\InputFilter\InputFilter; | ||
use ZendTest\Form\TestAsset\Entity; | ||
use ZendTest\Form\TestAsset\HydratorAwareModel; | ||
|
||
|
@@ -818,6 +818,35 @@ public function testBindValuesWithWrappingPopulatesBoundObject() | |
], $model->foobar); | ||
} | ||
|
||
public function testFormBaseFieldsetBindValuesWithoutInputs() | ||
{ | ||
$baseFieldset = new Fieldset('base_fieldset'); | ||
$baseFieldset->setUseAsBaseFieldset(true); | ||
|
||
$form = new Form('default_form'); | ||
$form->add($baseFieldset); | ||
$form->setHydrator(new ObjectPropertyHydrator()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
$baseFieldsetInputFilter = new InputFilter(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Did indeed not make a difference for patch. |
||
|
||
$formInputFilter = new InputFilter(); | ||
$formInputFilter->add($baseFieldsetInputFilter, 'base_fieldset'); | ||
|
||
$form->setInputFilter($formInputFilter); | ||
|
||
$model = new stdClass(); | ||
$form->bind($model); | ||
|
||
$data = [ | ||
'submit' => 'save', | ||
]; | ||
$form->setData($data); | ||
|
||
$form->isValid(); // Calls ->bindValues after validation (line: 817) | ||
|
||
$this->assertObjectNotHasAttribute('submit', $model); | ||
} | ||
|
||
public function testHasFactoryComposedByDefault() | ||
{ | ||
$factory = $this->form->getFormFactory(); | ||
|
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