Skip to content

Commit 6182d6d

Browse files
committed
Fix #17 - allow "predef_param" in checkbox filters
1 parent 61628f1 commit 6182d6d

File tree

2 files changed

+37
-10
lines changed

2 files changed

+37
-10
lines changed

src/FilterSetting/Checkbox.php

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,51 @@ public function prepareRules(IFilter $objFilter, $arrFilterUrl)
7373

7474
/**
7575
* {@inheritdoc}
76+
*
77+
* @SuppressWarnings(PHPMD.Superglobals)
78+
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
7679
*/
7780
public function getParameterDCA()
7881
{
7982
// If defined as static, return nothing as not to be manipulated via editors.
8083
if (!$this->get('predef_param')) {
81-
return array();
84+
return [];
8285
}
8386

8487
$objAttribute = $this->getMetaModel()->getAttributeById($this->get('attr_id'));
8588

86-
return array(
87-
$this->getParamName() => array
88-
(
89-
'label' => array(
90-
($this->get('label') ? $this->get('label') : $objAttribute->getName()),
91-
'GET: '.$this->get('urlparam')
92-
),
89+
if ($this->get('ynmode') == 'radio') {
90+
return [
91+
$this->getParamName() => [
92+
'label' => [
93+
($this->get('label') ? $this->get('label') : $objAttribute->getName()),
94+
'GET: '.$this->get('urlparam')
95+
],
96+
'inputType' => 'radio',
97+
'options' => [
98+
'-1' => '-1',
99+
'1' => '1'
100+
],
101+
'reference' => [
102+
'-1' => $GLOBALS['TL_LANG']['MSC']['no'],
103+
'1' => $GLOBALS['TL_LANG']['MSC']['yes']
104+
],
105+
'eval' => [
106+
'includeBlankOption' => $this->get('blankoption')
107+
]
108+
]
109+
];
110+
}
111+
112+
return [
113+
$this->getParamName() => [
114+
'label' => [
115+
($this->get('label') ? $this->get('label') : $objAttribute->getName()),
116+
'GET: '.$this->get('urlparam')
117+
],
93118
'inputType' => 'checkbox',
94-
)
95-
);
119+
]
120+
];
96121
}
97122

98123
/**

src/Resources/contao/dca/tl_metamodel_filtersetting.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
$GLOBALS['TL_DCA']['tl_metamodel_filtersetting']['metapalettes']['checkbox extends _attribute_']['+fefilter'][] =
2626
'urlparam';
27+
$GLOBALS['TL_DCA']['tl_metamodel_filtersetting']['metapalettes']['checkbox extends _attribute_']['+fefilter'][] =
28+
'predef_param';
2729
$GLOBALS['TL_DCA']['tl_metamodel_filtersetting']['metapalettes']['checkbox extends _attribute_']['+fefilter'][] =
2830
'label';
2931
$GLOBALS['TL_DCA']['tl_metamodel_filtersetting']['metapalettes']['checkbox extends _attribute_']['+fefilter'][] =

0 commit comments

Comments
 (0)