Skip to content

Commit

Permalink
fix(checkboxesfield,multiselectfield): default value not displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Jan 2, 2023
1 parent eecdf8a commit 8f36ab7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion inc/field/checkboxesfield.class.php
Expand Up @@ -50,10 +50,21 @@ public function isPrerequisites(): bool {
public function showForm(array $options): void {
$template = '@formcreator/field/' . $this->question->fields['fieldtype'] . 'field.html.twig';

$value = [];
$items = json_decode($this->question->fields['default_values']);
foreach ($items as $item) {
if (trim($item) === '') {
continue;
}
if (!in_array($item, $this->getAvailableValues())) {
continue;
}
$value[] = $item;
}
$this->question->fields['default_values'] = implode("\r\n", $value);
$this->question->fields['values'] = json_decode($this->question->fields['values']);
$this->question->fields['values'] = is_array($this->question->fields['values']) ? $this->question->fields['values'] : [];
$this->question->fields['values'] = implode("\r\n", $this->question->fields['values']);
$this->question->fields['default_values'] = Html::entities_deep($this->getValueForDesign());
$this->deserializeValue($this->question->fields['default_values']);

$parameters = $this->getParameters();
Expand Down

0 comments on commit 8f36ab7

Please sign in to comment.