This repository was archived by the owner on Jan 30, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +95
-0
lines changed Expand file tree Collapse file tree 3 files changed +95
-0
lines changed Original file line number Diff line number Diff line change @@ -679,6 +679,7 @@ public function getInputFilter()
679
679
$ name = $ this ->baseFieldset ->getName ();
680
680
if (!$ this ->filter instanceof InputFilterInterface || !$ this ->filter ->has ($ name )) {
681
681
$ filter = new InputFilter ();
682
+ $ filter ->setFactory ($ this ->getFormFactory ()->getInputFilterFactory ());
682
683
$ filter ->add ($ this ->object ->getInputFilter (), $ name );
683
684
$ this ->filter = $ filter ;
684
685
}
@@ -687,6 +688,7 @@ public function getInputFilter()
687
688
688
689
if (!isset ($ this ->filter )) {
689
690
$ this ->filter = new InputFilter ();
691
+ $ this ->filter ->setFactory ($ this ->getFormFactory ()->getInputFilterFactory ());
690
692
}
691
693
692
694
if (!$ this ->hasAddedInputFilterDefaults
Original file line number Diff line number Diff line change @@ -2135,4 +2135,27 @@ public function testSetValidationGroupOnFormWithNestedCollectionsPopulatesOnlyFi
2135
2135
2136
2136
$ this ->assertEquals ($ data , $ this ->form ->getData ());
2137
2137
}
2138
+
2139
+ /**
2140
+ * Test for https://github.com/zendframework/zend-form/pull/24#issue-119023527
2141
+ */
2142
+ public function testGetInputFilterInjectsFormInputFilterFactoryInstanceObjectIsNull ()
2143
+ {
2144
+ $ inputFilterFactory = $ this ->form ->getFormFactory ()->getInputFilterFactory ();
2145
+ $ inputFilter = $ this ->form ->getInputFilter ();
2146
+ $ this ->assertSame ($ inputFilterFactory , $ inputFilter ->getFactory ());
2147
+ }
2148
+
2149
+ /**
2150
+ * Test for https://github.com/zendframework/zend-form/pull/24#issuecomment-159905491
2151
+ */
2152
+ public function testGetInputFilterInjectsFormInputFilterFactoryInstanceWhenObjectIsInputFilterAware ()
2153
+ {
2154
+ $ this ->form ->setBaseFieldset (new Fieldset ());
2155
+ $ this ->form ->setHydrator (new Hydrator \ClassMethods ());
2156
+ $ this ->form ->bind (new TestAsset \Entity \Cat ());
2157
+ $ inputFilterFactory = $ this ->form ->getFormFactory ()->getInputFilterFactory ();
2158
+ $ inputFilter = $ this ->form ->getInputFilter ();
2159
+ $ this ->assertSame ($ inputFilterFactory , $ inputFilter ->getFactory ());
2160
+ }
2138
2161
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Zend Framework (http://framework.zend.com/)
4
+ *
5
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
6
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7
+ * @license http://framework.zend.com/license/new-bsd New BSD License
8
+ */
9
+
10
+ namespace ZendTest \Form \TestAsset \Entity ;
11
+
12
+ use Zend \InputFilter \InputFilter ;
13
+ use Zend \InputFilter \InputFilterInterface ;
14
+ use Zend \InputFilter \InputFilterAwareInterface ;
15
+
16
+ class Cat implements InputFilterAwareInterface
17
+ {
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $ name = null ;
22
+
23
+ /**
24
+ * @var InputFilterInterface
25
+ */
26
+ protected $ inputFilter = null ;
27
+
28
+ /**
29
+ * @param string $name
30
+ * @return Cat
31
+ */
32
+ public function setName ($ name )
33
+ {
34
+ $ this ->name = $ name ;
35
+ return $ this ;
36
+ }
37
+
38
+ /**
39
+ * @return string
40
+ */
41
+ public function getName ()
42
+ {
43
+ return $ this ->name ;
44
+ }
45
+
46
+ /**
47
+ * Set input filter
48
+ *
49
+ * @param InputFilterInterface $inputFilter
50
+ * @return Cat
51
+ */
52
+ public function setInputFilter (InputFilterInterface $ inputFilter )
53
+ {
54
+ $ this ->inputFilter = $ inputFilter ;
55
+ return $ this ;
56
+ }
57
+
58
+ /**
59
+ * Retrieve input filter
60
+ *
61
+ * @return InputFilterInterface
62
+ */
63
+ public function getInputFilter ()
64
+ {
65
+ if (null === $ this ->inputFilter ) {
66
+ $ this ->inputFilter = new InputFilter ();
67
+ }
68
+ return $ this ->inputFilter ;
69
+ }
70
+ }
You can’t perform that action at this time.
0 commit comments