@@ -212,10 +212,36 @@ public function getFilterType($dbType, $class, $columnName)
212
212
/**
213
213
* @param $formType
214
214
* @param $dbType
215
- * @param $columnName
215
+ * @param $model
216
+ * @param $fieldPath
216
217
* @return array
217
218
*/
218
219
public function getFormOptions ($ formType , $ dbType , $ model , $ fieldPath )
220
+ {
221
+ return $ this ->getOptions ($ formType , $ dbType , $ model , $ fieldPath , false );
222
+ }
223
+
224
+ /**
225
+ * @param $filterType
226
+ * @param $dbType
227
+ * @param $model
228
+ * @param $fieldPath
229
+ * @return array
230
+ */
231
+ public function getFilterOptions ($ filterType , $ dbType , $ model , $ fieldPath )
232
+ {
233
+ return $ this ->getOptions ($ filterType , $ dbType , $ model , $ fieldPath , true );
234
+ }
235
+
236
+ /**
237
+ * @param $type
238
+ * @param $dbType
239
+ * @param $model
240
+ * @param $fieldPath
241
+ * @param bool $filter
242
+ * @return array
243
+ */
244
+ protected function getOptions ($ type , $ dbType , $ model , $ fieldPath , $ filter = false )
219
245
{
220
246
if ('virtual ' === $ dbType ) {
221
247
return array ();
@@ -226,7 +252,7 @@ public function getFormOptions($formType, $dbType, $model, $fieldPath)
226
252
$ columnName = $ resolved ['field ' ];
227
253
228
254
if ((\PropelColumnTypes::BOOLEAN == $ dbType || \PropelColumnTypes::BOOLEAN_EMU == $ dbType ) &&
229
- (preg_match ("#^choice#i " , $ formType ) || preg_match ("#choice$#i " , $ formType ))) {
255
+ (preg_match ("#^choice#i " , $ type ) || preg_match ("#choice$#i " , $ type ))) {
230
256
return array (
231
257
'choices ' => array (
232
258
0 => 'boolean.no ' ,
@@ -237,14 +263,15 @@ public function getFormOptions($formType, $dbType, $model, $fieldPath)
237
263
);
238
264
}
239
265
240
- if ((\PropelColumnTypes::BOOLEAN == $ dbType || \PropelColumnTypes::BOOLEAN_EMU == $ dbType ) &&
241
- (preg_match ("#^checkbox#i " , $ formType ) || preg_match ("#checkbox#i " , $ formType ))) {
266
+ if (!$ filter &&
267
+ (\PropelColumnTypes::BOOLEAN == $ dbType || \PropelColumnTypes::BOOLEAN_EMU == $ dbType ) &&
268
+ (preg_match ("#^checkbox#i " , $ type ) || preg_match ("#checkbox#i " , $ type ))) {
242
269
return array (
243
270
'required ' => false
244
271
);
245
272
}
246
273
247
- if (preg_match ("#^model#i " , $ formType ) || preg_match ("#model$#i " , $ formType )) {
274
+ if (preg_match ("#^model#i " , $ type ) || preg_match ("#model$#i " , $ type )) {
248
275
$ relation = $ this ->getRelation ($ columnName , $ class );
249
276
if ($ relation ) {
250
277
if (\RelationMap::MANY_TO_ONE === $ relation ->getType ()) {
@@ -261,7 +288,7 @@ public function getFormOptions($formType, $dbType, $model, $fieldPath)
261
288
}
262
289
}
263
290
264
- if (preg_match ("#^collection#i " , $ formType ) || preg_match ("#collection$#i " , $ formType )) {
291
+ if (preg_match ("#^collection#i " , $ type ) || preg_match ("#collection$#i " , $ type )) {
265
292
$ relation = $ this ->getRelation ($ columnName , $ class );
266
293
267
294
return array (
@@ -279,12 +306,12 @@ public function getFormOptions($formType, $dbType, $model, $fieldPath)
279
306
$ valueSet = $ this ->getMetadatas ($ class )->getColumn ($ class , $ columnName )->getValueSet ();
280
307
281
308
return array (
282
- 'required ' => $ this ->isRequired ($ class , $ columnName ),
309
+ 'required ' => $ filter ? false : $ this ->isRequired ($ class , $ columnName ),
283
310
'choices ' => array_combine ($ valueSet , $ valueSet ),
284
311
);
285
312
}
286
313
287
- return array ('required ' => $ this ->isRequired ($ class , $ columnName ));
314
+ return array ('required ' => $ filter ? false : $ this ->isRequired ($ class , $ columnName ));
288
315
}
289
316
290
317
protected function isRequired ($ class , $ fieldName )
0 commit comments