mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
[filterOrder] fix error in method getActiveFilters when dealing with entityChoice with incorrect number of translation
This commit is contained in:
parent
39896ea6e2
commit
43419f9f15
@ -84,9 +84,11 @@ final class FilterOrderHelper
|
|||||||
|
|
||||||
public function addCheckbox(string $name, array $choices, ?array $default = [], ?array $trans = [], array $options = []): self
|
public function addCheckbox(string $name, array $choices, ?array $default = [], ?array $trans = [], array $options = []): self
|
||||||
{
|
{
|
||||||
$missing = count($choices) - count($trans) - 1;
|
$missing = count($choices) - count($trans);
|
||||||
|
|
||||||
$this->checkboxes[$name] = [
|
$this->checkboxes[$name] = [
|
||||||
'choices' => $choices, 'default' => $default,
|
'choices' => $choices,
|
||||||
|
'default' => $default,
|
||||||
'trans' => array_merge(
|
'trans' => array_merge(
|
||||||
$trans,
|
$trans,
|
||||||
0 < $missing ?
|
0 < $missing ?
|
||||||
@ -223,9 +225,10 @@ final class FilterOrderHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->checkboxes as $name => ['choices' => $choices, 'trans' => $trans, 'options' => $options]) {
|
foreach ($this->checkboxes as $name => ['choices' => $choices, 'trans' => $trans]) {
|
||||||
|
$translatedChoice = array_combine($choices, [...$trans]);
|
||||||
foreach ($this->getCheckboxData($name) as $keyChoice) {
|
foreach ($this->getCheckboxData($name) as $keyChoice) {
|
||||||
$result[] = ['value' => $choices['keyChoice'], 'label' => $options['label'], 'position' => FilterOrderPositionEnum::Checkboxes->value, 'name' => $name];
|
$result[] = ['value' => $translatedChoice[$keyChoice], 'label' => '', 'position' => FilterOrderPositionEnum::Checkboxes->value, 'name' => $name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +240,7 @@ final class FilterOrderHelper
|
|||||||
$value = $this->propertyAccessor->getValue($selected, $options['choice_label']);
|
$value = $this->propertyAccessor->getValue($selected, $options['choice_label']);
|
||||||
} else {
|
} else {
|
||||||
if (!$selected instanceof \Stringable) {
|
if (!$selected instanceof \Stringable) {
|
||||||
throw new \UnexpectedValueException(sprintf("we are not able to transform the value of %s to a string. Implements \Stringable or add a 'choice_label' option to the filterFormBuilder", get_class($selected)));
|
throw new \UnexpectedValueException(sprintf("we are not able to transform the value of %s to a string. Implements \\Stringable or add a 'choice_label' option to the filterFormBuilder", get_class($selected)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$value = (string) $selected;
|
$value = (string) $selected;
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Chill\MainBundle\Templating\Listing;
|
namespace Chill\MainBundle\Templating\Listing;
|
||||||
|
|
||||||
enum FilterOrderPositionEnum: string
|
enum FilterOrderPositionEnum: string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user