Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent nested block config values from conflicting #42

Merged
merged 1 commit into from
Jan 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions formwidgets/Blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ class Blocks extends Repeater
*/
public string|array|null $tags = null;

/**
* List of inspector configs for the blocks.
*/
public array $inspectorConfigs = [];

/**
* Configuration stored with each index.
*/
Expand Down Expand Up @@ -212,10 +207,9 @@ protected function processGroupMode(): void
'name' => array_get($config, 'name'),
'icon' => array_get($config, 'icon', 'icon-square-o'),
'description' => array_get($config, 'description'),
'fields' => array_get($config, 'fields')
'fields' => array_get($config, 'fields'),
'config' => array_get($config, 'config', null),
];

$this->inspectorConfigs[$code] = array_get($config, 'config', null);
}

// Sort the builder blocks by translated name label
Expand Down Expand Up @@ -299,15 +293,15 @@ public function getGroupIcon(string $groupCode): ?string
*/
public function hasInspectorConfig(string $groupCode): bool
{
return isset($this->inspectorConfigs[$groupCode]);
return isset($this->groupDefinitions[$groupCode]['config']);
}

/**
* Returns the Inspector config, as a JSON string, for the given group code.
*/
public function getInspectorConfig(string $groupCode): string
{
return json_encode($this->processInspectorConfig(array_get($this->inspectorConfigs, $groupCode, [])));
return json_encode($this->processInspectorConfig(array_get($this->groupDefinitions, $groupCode . '.config', [])));
}

/**
Expand Down
Loading