Skip to content

Commit

Permalink
Merge pull request #84 from helsingborg-stad/3.0/fix/notices-form-bui…
Browse files Browse the repository at this point in the history
…lder

3.0/fix/notices form builder
  • Loading branch information
Anna authored Sep 8, 2023
2 parents 2a34fc5 + cad3420 commit 03c5bbf
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
12 changes: 7 additions & 5 deletions source/php/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,13 @@ public function updateFieldKeys($postId)
}

// Loop through all other field labels
if ($fieldObject['_name'] == 'label' && !empty($oldValues[$key][$fieldKey]) && $newValues[$key][$fieldKey] != $oldValues[$key][$fieldKey]) {
$updatedValues[] = array(
'old' => sanitize_title($oldValues[$key][$fieldKey]),
'new' => sanitize_title($newValues[$key][$fieldKey])
);
if (is_array($newValues[$key][$fieldKey]) && is_array($oldValues[$key][$fieldKey])) {
if ($fieldObject['_name'] == 'label' && !empty($oldValues[$key][$fieldKey]) && $newValues[$key][$fieldKey] != $oldValues[$key][$fieldKey]) {
$updatedValues[] = array(
'old' => sanitize_title($oldValues[$key][$fieldKey]),
'new' => sanitize_title($newValues[$key][$fieldKey])
);
}
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions source/php/Module/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,10 @@ private function setAttributeList($field)

$field['attributeList'] = [];

if (!empty($field['value_type']) && $field['value_type' === 'date']) {
$field['attributeList']['min'] = SanitizeData::formatDate($field['min_value']);
$field['attributeList']['max'] = SanitizeData::formatDate($field['max_value']);

if (!empty($field['value_type']) && $field['value_type'] === 'date') {
$field['attributeList']['min'] = \ModularityFormBuilder\Helper\SanitizeData::formatDate($field['min_value']);
$field['attributeList']['max'] = \ModularityFormBuilder\Helper\SanitizeData::formatDate($field['max_value']);
} elseif (!empty($field['value_type']) && $field['value_type'] === 'time') {
$field['attributeList']['min'] = trim($field['min_time_value']);
$field['attributeList']['max'] = trim($field['max_time_value']);
Expand Down
2 changes: 1 addition & 1 deletion source/php/Module/views/fields/checkbox.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class="form-group c-field checkbox-group {{$field['required'] ? 'checkbox-group-
'value' => $value['value'],
'label' => $value['value'],
'attributeList' => [
'conditional' => $value['conditional_value'],
'conditional' => !empty($value['conditional_value']) ? $value['conditional_value'] : false,
'name' => sanitize_title($field['label']) . '[]',
]
])
Expand Down
2 changes: 1 addition & 1 deletion source/php/Module/views/fields/input.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'label' => $field['label'],
'type' => $field['value_type'],
'value' => '',
'invalidMessage' => $field['invalidMessages'][$field['value_type']],
'invalidMessage' => !empty($field['invalidMessages'][$field['value_type']]) ? $field['invalidMessages'][$field['value_type']] : 'Invalid value',
'name' => sanitize_title($field['label']),
'description' => (!empty($field['description'])) ? ModularityFormBuilder\Helper\SanitizeData::convertLinks(
$field['description']
Expand Down
8 changes: 4 additions & 4 deletions source/php/Module/views/fields/sender.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
'type' => 'number',
'id' => $module_id . "-phone-" . uniqid(),
'invalidMessage' => $field['invalidMessages']['number'],
'value' => $user_details['phone'],
'value' => !empty($user_details['phone']) ? $user_details['phone'] : false,
'name' => sanitize_title($field['labels']['phone']),
'required' => in_array('phone', $field['required_fields']),
'autocomplete' => 'tel',
Expand Down Expand Up @@ -163,7 +163,7 @@
'label' => $field['labels']['street_address'],
'type' => 'text',
'id' => $module_id . "-address-street-" . uniqid(),
'value' => $user_details['address'],
'value' => !empty($user_details['address']) ? $user_details['address'] : false,
'name' => sanitize_title($field['labels']['address']) . '[' . sanitize_title($field['labels']['street_address']) . ']',
'required' => in_array('address', $field['required_fields']),
'autocomplete' => 'street-address',
Expand All @@ -182,7 +182,7 @@
'type' => 'number',
'id' => $module_id . "-address-postal-code-" . uniqid(),
'invalidMessage' => $field['invalidMessages']['number'],
'value' => $user_details['postal_code'],
'value' => !empty($user_details['postal_code']) ? $user_details['postal_code'] : false,
'name' => sanitize_title($field['labels']['address']) . '[' . sanitize_title($field['labels']['postal_code']) . ']',
'required' => in_array('postal_code', $field['required_fields']),
'autocomplete' => 'postal-code'
Expand All @@ -196,7 +196,7 @@
'label' => $field['labels']['city'],
'type' => 'text',
'id' => $module_id . "-address-city-" . uniqid(),
'value' => $user_details['city'],
'value' => !empty($user_details['city']) ? $user_details['city'] : false,
'name' => sanitize_title($field['labels']['address']) . '[' . sanitize_title($field['labels']['city']) . ']',
'required' => in_array('city', $field['required_fields']),
'autocomplete' => 'on'
Expand Down

0 comments on commit 03c5bbf

Please sign in to comment.