Skip to content

Commit 3ebdccf

Browse files
committed
Fix wrong initialization of grid filter options
1 parent 8fc0674 commit 3ebdccf

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

Component/Grid/GridViewModel.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Loki\AdminComponents\Component\Grid;
44

5+
use Magento\Framework\Data\OptionSourceInterface;
56
use Magento\Framework\DataObject;
67
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
78
use Magento\Framework\ObjectManagerInterface;
@@ -271,16 +272,20 @@ public function getFilterFields(): array
271272

272273
$fields = [];
273274
foreach ($filters as $filterCode => $filter) {
274-
$field = $this->fieldFactory->createWithBlock(
275-
$filter['field_type'],
276-
$filter['label'],
277-
$filterCode,
278-
);
275+
$filter['code'] = $filterCode;
279276

280-
if (isset($filter['options']) && is_string($filter['options'])) {
277+
if (isset($filter['options']) && false === $filter['options'] instanceof OptionSourceInterface) {
281278
$filter['options'] = $this->objectManager->get($filter['options']);
282279
}
283280

281+
if (isset($filter['options']) && false === $filter['options'] instanceof OptionSourceInterface) {
282+
throw new \RuntimeException('Filter uses wrong options class');
283+
}
284+
285+
$field = $this->fieldFactory->createWithBlock(
286+
$filter,
287+
);
288+
284289
$field->getBlock()->addData($filter);
285290
$field->getBlock()->setField($field);
286291
$fields[] = $field;

0 commit comments

Comments
 (0)