Skip to content

Commit

Permalink
Allow empty distribution and email in UI form if schema allows (#3986)
Browse files Browse the repository at this point in the history
* Allow for empty distribution in data node form.
* Only set mailto as data if there is an email.
  • Loading branch information
jastraat authored Jul 5, 2023
1 parent ab6dcb7 commit 502e249
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions modules/json_form_widget/src/ValueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public function flattenValues($formValues, $property, $schema) {
switch ($schema->type) {
case 'string':
$data = $this->handleStringValues($formValues, $property);
if ($property === 'hasEmail') {
$data = 'mailto:' . ltrim($data ?? '', 'mailto:');
if ($property === 'hasEmail' && is_string($data)) {
$data = 'mailto:' . ltrim($data, 'mailto:');
}
break;

Expand Down Expand Up @@ -180,10 +180,12 @@ private function cleanSelectId($value) {
*/
private function getObjectInArrayData($formValues, $property, $schema) {
$data = [];
foreach ($formValues[$property][$property] as $key => $item) {
$value = $this->handleObjectValues($formValues[$property][$property][$key][$property], $property, $schema);
if ($value) {
$data[$key] = $value;
if (isset($formValues[$property][$property])) {
foreach ($formValues[$property][$property] as $key => $item) {
$value = $this->handleObjectValues($formValues[$property][$property][$key][$property], $property, $schema);
if ($value) {
$data[$key] = $value;
}
}
}
return $data;
Expand Down

0 comments on commit 502e249

Please sign in to comment.