Skip to content

Commit

Permalink
IndexFieldSelection preSelect can also be integer (#192)
Browse files Browse the repository at this point in the history
When you use Index Service to index a relation, the ids are stored in database in INT column.
When you try to use this indexed value in the filter and pre select a value, it cannot be saved because of the typehint.

Steps to reproduce:
1. create a DataObject for FilterDefinition
2. add a "Filter Relation" to Filters
3. chose a value for "Pre Select" field
4. save the DataObject
  • Loading branch information
mhujer authored Aug 27, 2024
1 parent 409e576 commit 2202858
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/CoreExtensions/ObjectData/IndexFieldSelection.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class IndexFieldSelection
public string $field;

/**
* @var string|string[]|null
* @var string|string[]|int|null
*/
public string|array|null $preSelect;
public string|array|int|null $preSelect;

/**
* @param string|string[] $preSelect
* @param string|string[]|int $preSelect
*/
public function __construct(?string $tenant, string $field, array|string|null $preSelect)
public function __construct(?string $tenant, string $field, array|string|int|null $preSelect)
{
$this->field = $field;
$this->preSelect = $preSelect;
Expand All @@ -50,15 +50,15 @@ public function getField(): string
/**
* @param string|string[] $preSelect
*/
public function setPreSelect(array|string $preSelect): void
public function setPreSelect(array|string|int $preSelect): void
{
$this->preSelect = $preSelect;
}

/**
* @return string|string[]|null
*/
public function getPreSelect(): array|string|null
public function getPreSelect(): array|string|int|null
{
return $this->preSelect;
}
Expand Down
2 changes: 1 addition & 1 deletion src/FilterService/FilterType/AbstractFilterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function getTemplate(AbstractFilterDefinitionType $filterDefinition):
return $template;
}

protected function getPreSelect(AbstractFilterDefinitionType $filterDefinition): array|string|null
protected function getPreSelect(AbstractFilterDefinitionType $filterDefinition): array|string|int|null
{
$field = $filterDefinition->getField();
if ($field instanceof IndexFieldSelection) {
Expand Down

0 comments on commit 2202858

Please sign in to comment.