diff --git a/plugi-core/src/Modules/GrapesJS/Block/BlockAdapter.php b/plugi-core/src/Modules/GrapesJS/Block/BlockAdapter.php index fdd2556..ead9581 100644 --- a/plugi-core/src/Modules/GrapesJS/Block/BlockAdapter.php +++ b/plugi-core/src/Modules/GrapesJS/Block/BlockAdapter.php @@ -133,12 +133,12 @@ class BlockAdapter ]; if ($type === 'select') { - $setting['options'] = $blockSetting['options'] ?? []; + $setting['options'] = $this->normalizeSelectOptions($blockSetting['options'] ?? []); } elseif ($type === 'yes_no') { $setting['type'] = 'select'; $setting['options'] = [ - ['id' => 0, 'name' => phpb_trans('pagebuilder.no')], - ['id' => 1, 'name' => phpb_trans('pagebuilder.yes')] + ['id' => 0, 'label' => phpb_trans('pagebuilder.no')], + ['id' => 1, 'label' => phpb_trans('pagebuilder.yes')] ]; } @@ -147,4 +147,24 @@ class BlockAdapter return $settings; } + + /** + * Normalize select options to use GrapesJS trait format. + * GrapesJS expects options with 'id' (stored value) and 'label' (display text), + * but block configs may use 'id' and 'name'. + * + * @param array $options + * @return array + */ + protected function normalizeSelectOptions($options) + { + $normalized = []; + foreach ($options as $option) { + $normalized[] = [ + 'id' => $option['id'] ?? $option['value'] ?? '', + 'label' => $option['name'] ?? $option['label'] ?? '', + ]; + } + return $normalized; + } }