Have you searched through other issues to see if your problem is already reported or has been fixed?
Yes, I did not find it.
Did you read the documentation?
Yes, I did not find it.
Have you tried to publish the views?
Yes - I didn't work.
Is there an error in the console?
No
PHP Version
No response
PowerGrid
No response
Laravel
No response
Livewire
No response
Alpine JS
No response
Theme
Bootstrap
Describe the bug.
In the FilterEnumSelect class, the execute method has an issue where the $optionLabel is always set to 'value' at the beginning of the method. This behavior overrides any previous attempts to set a custom label field for the filter, leading to unexpected results.
Problem:
The $optionLabel variable is initialized with 'value' and is only updated to 'name' if a specific condition is met. This initialization means that the initial value ('value') always overrides any previously set label field, which can cause issues if users want to customize the label field for their filters.
Expected Behavior:
The optionLabel should retain any user-defined label fields rather than being overwritten by the default 'value'.
To Reproduce...
No response
Extra information
public function execute(): FilterEnumSelect
{
$optionLabel = 'value';
$collection = collect($this->dataSource)->map(function ($case) use (&$optionLabel) {
$option = (array) $case;
if (method_exists($case, 'labelPowergridFilter')) {
$option['name'] = $case->labelPowergridFilter();
$optionLabel = 'name';
}
return $option;
});
$this->dataSource($collection);
$this->optionLabel($optionLabel);
$this->optionValue($this->optionValue);
return $this;
}
Have you searched through other issues to see if your problem is already reported or has been fixed?
Yes, I did not find it.
Did you read the documentation?
Yes, I did not find it.
Have you tried to publish the views?
Yes - I didn't work.
Is there an error in the console?
No
PHP Version
No response
PowerGrid
No response
Laravel
No response
Livewire
No response
Alpine JS
No response
Theme
Bootstrap
Describe the bug.
In the FilterEnumSelect class, the execute method has an issue where the $optionLabel is always set to 'value' at the beginning of the method. This behavior overrides any previous attempts to set a custom label field for the filter, leading to unexpected results.
Problem:
The $optionLabel variable is initialized with 'value' and is only updated to 'name' if a specific condition is met. This initialization means that the initial value ('value') always overrides any previously set label field, which can cause issues if users want to customize the label field for their filters.
Expected Behavior:
The optionLabel should retain any user-defined label fields rather than being overwritten by the default 'value'.
To Reproduce...
No response
Extra information