mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +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)
|
public function isChecked(CustomField $cf, $choiceSlug, $data)
|
||||||
{
|
{
|
||||||
$deserialized = $this->deserialize($data, $cf);
|
if ($data === null) {
|
||||||
|
|
||||||
if ($deserialized === null) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dump($deserialized);
|
|
||||||
if ($cf->getOptions()[self::MULTIPLE]) {
|
if ($cf->getOptions()[self::MULTIPLE]) {
|
||||||
|
if ($cf->getOptions()[self::ALLOW_OTHER]) {
|
||||||
return \in_array($choiceSlug, $deserialized);
|
return \in_array($choiceSlug, $data['_choices']);
|
||||||
|
} else {
|
||||||
|
return \in_array($choiceSlug, $data);
|
||||||
|
}
|
||||||
} else {
|
} 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)
|
public function extractOtherValue(CustomField $cf, array $data = null)
|
||||||
{
|
{
|
||||||
dump('extracting');
|
|
||||||
dump($data);
|
|
||||||
return $data['_other'];
|
return $data['_other'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ services:
|
|||||||
class: Chill\CustomFieldsBundle\Service\CustomFieldProvider
|
class: Chill\CustomFieldsBundle\Service\CustomFieldProvider
|
||||||
call:
|
call:
|
||||||
- [setContainer, ["@service_container"]]
|
- [setContainer, ["@service_container"]]
|
||||||
|
Chill\CustomFieldsBundle\Service\CustomFieldProvider: '@chill.custom_field.provider'
|
||||||
|
|
||||||
chill.custom_field.custom_field_choice_type:
|
chill.custom_field.custom_field_choice_type:
|
||||||
class: Chill\CustomFieldsBundle\Form\CustomFieldType
|
class: Chill\CustomFieldsBundle\Form\CustomFieldType
|
||||||
|
Loading…
x
Reference in New Issue
Block a user