mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
Improve isChecked
This commit is contained in:
parent
0371236493
commit
23e68416a2
@ -363,17 +363,22 @@ class CustomFieldChoice extends AbstractCustomField
|
||||
|
||||
public function isChecked(CustomField $cf, $choiceSlug, $data)
|
||||
{
|
||||
$deserialized = $this->deserialize($data, $cf);
|
||||
|
||||
if ($deserialized === null) {
|
||||
if ($data === null) {
|
||||
return false;
|
||||
}
|
||||
dump($deserialized);
|
||||
|
||||
if ($cf->getOptions()[self::MULTIPLE]) {
|
||||
|
||||
return \in_array($choiceSlug, $deserialized);
|
||||
if ($cf->getOptions()[self::ALLOW_OTHER]) {
|
||||
return \in_array($choiceSlug, $data['_choices']);
|
||||
} else {
|
||||
return \in_array($choiceSlug, $data);
|
||||
}
|
||||
} else {
|
||||
return $data === $choiceSlug;
|
||||
if ($cf->getOptions()[self::ALLOW_OTHER]) {
|
||||
return $data['_choices'] === $choiceSlug;
|
||||
} else {
|
||||
return $data === $choiceSlug;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -389,8 +394,6 @@ class CustomFieldChoice extends AbstractCustomField
|
||||
|
||||
public function extractOtherValue(CustomField $cf, array $data = null)
|
||||
{
|
||||
dump('extracting');
|
||||
dump($data);
|
||||
return $data['_other'];
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ services:
|
||||
class: Chill\CustomFieldsBundle\Service\CustomFieldProvider
|
||||
call:
|
||||
- [setContainer, ["@service_container"]]
|
||||
Chill\CustomFieldsBundle\Service\CustomFieldProvider: '@chill.custom_field.provider'
|
||||
|
||||
chill.custom_field.custom_field_choice_type:
|
||||
class: Chill\CustomFieldsBundle\Form\CustomFieldType
|
||||
|
Loading…
x
Reference in New Issue
Block a user