File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -2511,7 +2511,7 @@ function invalidFields($options = array()) {
2511
2511
$ _validate = $ this ->validate ;
2512
2512
$ whitelist = $ this ->whitelist ;
2513
2513
2514
- if (array_key_exists ( 'fieldList ' , $ options )) {
2514
+ if (! empty ( $ options [ 'fieldList ' ] )) {
2515
2515
$ whitelist = $ options ['fieldList ' ];
2516
2516
}
2517
2517
Original file line number Diff line number Diff line change @@ -164,11 +164,34 @@ function testInvalidFieldsWithFieldListParams() {
164
164
$ TestModel ->invalidFields ();
165
165
$ expected = array ('name ' => 'This field cannot be left blank ' );
166
166
$ this ->assertEqual ($ TestModel ->validationErrors , $ expected );
167
- $ TestModel ->validationErrors = array ();
168
167
169
168
$ this ->assertEqual ($ TestModel ->validate , $ validate );
170
169
}
171
170
171
+ /**
172
+ * Test that invalidFields() integrates well with save(). And that fieldList can be an empty type.
173
+ *
174
+ * @return void
175
+ */
176
+ function testInvalidFieldsWhitelist () {
177
+ $ TestModel =& new ValidationTest1 ();
178
+ $ TestModel ->validate = $ validate = array (
179
+ 'title ' => array (
180
+ 'rule ' => 'customValidator ' ,
181
+ 'required ' => true
182
+ ),
183
+ 'name ' => array (
184
+ 'rule ' => 'alphaNumeric ' ,
185
+ 'required ' => true
186
+ ));
187
+
188
+ $ TestModel ->whitelist = array ('name ' );
189
+ $ TestModel ->save (array ('name ' => '#$$# ' ));
190
+
191
+ $ expected = array ('name ' => 'This field cannot be left blank ' );
192
+ $ this ->assertEqual ($ TestModel ->validationErrors , $ expected );
193
+ }
194
+
172
195
/**
173
196
* testValidates method
174
197
*
You can’t perform that action at this time.
0 commit comments