diff --git a/modules/extravar/models/Value.php b/modules/extravar/models/Value.php index 9ef8f983a..9028de37f 100644 --- a/modules/extravar/models/Value.php +++ b/modules/extravar/models/Value.php @@ -150,7 +150,6 @@ class Value 'type' => $this->type, 'value' => self::_getTypeValue($this->type, $this->value), 'default' => self::_getTypeValue($this->type, $this->default), - 'options' => $this->getOptions(), 'input_name' => $this->parent_type === 'document' ? ('extra_vars' . $this->idx) : ($this->input_name ?: $this->eid), 'input_id' => $this->input_id ?: '', ]); @@ -158,13 +157,24 @@ class Value } /** - * Check if the current value can have options. + * Get the default value. * - * @return bool + * @return mixed */ - public function canHaveOptions(): bool + public function getDefaultValue() { - return isset(self::OPTION_TYPES[$this->type]); + if (!$this->canHaveOptions()) + { + return $this->default; + } + elseif (is_array($this->options)) + { + return $this->default; + } + else + { + return null; + } } /** @@ -193,6 +203,16 @@ class Value } } + /** + * Check if the current value can have options. + * + * @return bool + */ + public function canHaveOptions(): bool + { + return isset(self::OPTION_TYPES[$this->type]); + } + /** * Get the next temporary ID. * diff --git a/modules/extravar/skins/default/form_types/checkbox.blade.php b/modules/extravar/skins/default/form_types/checkbox.blade.php index 0d99d20c9..7087263a2 100644 --- a/modules/extravar/skins/default/form_types/checkbox.blade.php +++ b/modules/extravar/skins/default/form_types/checkbox.blade.php @@ -1,10 +1,15 @@ +@php + $has_value = is_array($value); + $default_value = $definition->getDefaultValue(); +@endphp + @if ($parent_type === 'member')