Skip to content

Commit 7e425f3

Browse files
committed
added key as a filter property instead of option
1 parent 92f8c35 commit 7e425f3

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/app/Library/CrudPanel/CrudFilter.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class CrudFilter
99
{
1010
public $name; // the name of the filtered variable (db column name)
1111
public $type = 'select2'; // the name of the filter view that will be loaded
12+
public $key; //camelCased version of filter name to use in internal ids, js functions and css classes.
1213
public $label;
1314
public $placeholder;
1415
public $values;
@@ -22,9 +23,6 @@ class CrudFilter
2223

2324
public function __construct($options, $values, $logic, $fallbackLogic)
2425
{
25-
//we use the key in filters for properties, js functions etc. We leave the name untouched for beeing sent in request.
26-
$options['key'] = Str::camel($options['key']);
27-
2826
// if filter exists
2927
if ($this->crud()->hasFilterWhere('name', $options['name'])) {
3028
$properties = get_object_vars($this->crud()->firstFilterWhere('name', $options['name']));
@@ -34,6 +32,7 @@ public function __construct($options, $values, $logic, $fallbackLogic)
3432
} else {
3533
// it means we're creating the filter now,
3634
$this->name = $options['name'];
35+
$this->key = Str::camel($options['name']);
3736
$this->type = $options['type'] ?? $this->type;
3837
$this->label = $options['label'] ?? $this->crud()->makeLabel($this->name);
3938
$this->viewNamespace = $options['view_namespace'] ?? $this->viewNamespace;

src/app/Library/CrudPanel/Traits/Filters.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ protected function addFilterToCollection($options, $values = false, $filterLogic
8181
abort(500, "Sorry, you can't have two filters with the same name.");
8282
}
8383

84-
//we use the key in filters for properties, js functions etc. We leave the name untouched for beeing sent in request.
85-
$options['key'] = Str::camel($options['name']);
86-
8784
// add a new filter to the interface
8885
$filter = new CrudFilter($options, $values, $filterLogic, $fallbackLogic);
8986
$this->setOperationSetting('filters', $this->filters()->push($filter));

0 commit comments

Comments
 (0)