Skip to content

Commit a6b7ac4

Browse files
committed
fix: include empty keys
1 parent 3dc1f35 commit a6b7ac4

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/EditableKeyValueField.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,14 @@ public function getFormField()
4848

4949
public function getValueFromData($data)
5050
{
51-
$incoming = isset($data[$this->Name]) ? $data[$this->Name] : false;
52-
53-
if (!$incoming) {
54-
return json_encode([]);
55-
}
56-
51+
$incoming = isset($data[$this->Name]) ? $data[$this->Name] : [];
5752
$value = [];
5853

5954
foreach ($this->getKeysAsArray() as $i => $k) {
60-
if (isset($data[$i])) {
61-
$value[$k] = $data[$i];
55+
if (isset($incoming[$i])) {
56+
$value[$k] = $incoming[$i];
57+
} else {
58+
$value[$k] = '';
6259
}
6360
}
6461

src/SubmittedKeyValueField.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class SubmittedKeyValueFormField extends SubmittedFormField
99
{
1010
private static $table_name = 'SubmittedKeyValueFormField';
1111

12-
1312
public function getFormattedValue()
1413
{
1514
$data = json_decode($this->Value, true);

0 commit comments

Comments
 (0)