Skip to content

Commit

Permalink
Send and process empty setting arrays as __empty__
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkleiner committed Dec 19, 2024
1 parent c7c1027 commit 38ba77f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
7 changes: 7 additions & 0 deletions plugins/CorePluginsAdmin/SettingsMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class SettingsMetadata
{
public const PASSWORD_PLACEHOLDER = '******';

public const EMPTY_ARRAY = '__empty__';

/**
* @param Settings[] $settingsInstances
* @param array $settingValues array('pluginName' => array('settingName' => 'settingValue'))
Expand All @@ -34,6 +36,11 @@ public function setPluginSettings($settingsInstances, $settingValues)

$fieldConfig = $setting->configureField();

// empty arrays are sent as __empty__ value, so we need to convert it here back to an array
if ($setting->getType() === FieldConfig::TYPE_ARRAY && $value === self::EMPTY_ARRAY) {
$value = [];
}

if (
isset($value) && (
$fieldConfig->uiControl !== FieldConfig::UI_CONTROL_PASSWORD ||
Expand Down
32 changes: 18 additions & 14 deletions plugins/CorePluginsAdmin/vue/dist/CorePluginsAdmin.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 38ba77f

Please sign in to comment.