mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
allow to render choice in different columns
This commit is contained in:
parent
2042e43613
commit
0371236493
@ -330,4 +330,67 @@ class CustomFieldChoice extends AbstractCustomField
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getChoices(CustomField $cf)
|
||||
{
|
||||
if ($cf->getOptions()[self::MULTIPLE]) {
|
||||
$choices = array();
|
||||
|
||||
foreach ($cf->getOptions()[self::CHOICES] as $choice) {
|
||||
if ($choices['active'] === false) {
|
||||
continue;
|
||||
}
|
||||
$choices[$choice["slug"]] = $this->translatableStringHelper
|
||||
->localize($choice["name"]);
|
||||
}
|
||||
|
||||
if ($this->allowOtherChoice($cf)) {
|
||||
$labels = $cf->getOptions()[self::OTHER_VALUE_LABEL];
|
||||
if (!is_array($labels) or count($labels) === 0) {
|
||||
$labels['back'] = 'other value';
|
||||
}
|
||||
$choices['_other'] = $this->translatableStringHelper
|
||||
->localize($labels);
|
||||
}
|
||||
|
||||
return $choices;
|
||||
} else {
|
||||
return [
|
||||
$cf->getSlug() => $this->translatableStringHelper->localize($cf->getName())
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function isChecked(CustomField $cf, $choiceSlug, $data)
|
||||
{
|
||||
$deserialized = $this->deserialize($data, $cf);
|
||||
|
||||
if ($deserialized === null) {
|
||||
return false;
|
||||
}
|
||||
dump($deserialized);
|
||||
if ($cf->getOptions()[self::MULTIPLE]) {
|
||||
|
||||
return \in_array($choiceSlug, $deserialized);
|
||||
} else {
|
||||
return $data === $choiceSlug;
|
||||
}
|
||||
}
|
||||
|
||||
public function isMultiple(CustomField $cf)
|
||||
{
|
||||
return $cf->getOptions()[self::MULTIPLE];
|
||||
}
|
||||
|
||||
public function allowOtherChoice(CustomField $cf)
|
||||
{
|
||||
return $cf->getOptions()[self::ALLOW_OTHER];
|
||||
}
|
||||
|
||||
public function extractOtherValue(CustomField $cf, array $data = null)
|
||||
{
|
||||
dump('extracting');
|
||||
dump($data);
|
||||
return $data['_other'];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user