Skip to content

Commit

Permalink
Add checks to json_form_widget
Browse files Browse the repository at this point in the history
  • Loading branch information
janette committed Dec 21, 2022
1 parent 6cd2c18 commit 115b220
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions modules/json_form_widget/src/ValueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ public function handleArrayValues($formValues, $property, $schema) {
if ($subschema->type === "object") {
return $this->getObjectInArrayData($formValues, $property, $subschema);
}

foreach ($formValues[$property][$property] as $value) {
$data = array_merge($data, $this->flattenArraysInArrays($value));
if (isset($formValues[$property][$property])) {
foreach ($formValues[$property][$property] as $value) {
$data = array_merge($data, $this->flattenArraysInArrays($value));
}
}

return !empty($data) ? $data : FALSE;
}

Expand Down
3 changes: 3 additions & 0 deletions modules/json_form_widget/src/WidgetRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ public function getDropdownElement($element, $spec, $titleProperty = FALSE) {
$element = $this->handleSelectOtherDefaultValue($element, $element['#options']);
$element['#input_type'] = isset($spec->other_type) ? $spec->other_type : 'textfield';
}
if (!isset($element['#other_option'])) {
$element['#other_option'] = '';
}
if ($element['#type'] === 'select2') {
$element['#multiple'] = isset($spec->multiple) ? TRUE : FALSE;
$element['#autocreate'] = isset($spec->allowCreate) ? TRUE : FALSE;
Expand Down

0 comments on commit 115b220

Please sign in to comment.