Skip to content

Commit df4b15f

Browse files
author
Sebastian Thulin
committed
Merge branch 'main' of github.com:helsingborg-stad/modularity-frontend-form
2 parents 9054af9 + 5ef9054 commit df4b15f

File tree

3 files changed

+8
-58
lines changed

3 files changed

+8
-58
lines changed

source/php/Module/FormatSteps.php

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -156,26 +156,10 @@ private function mapUrl(array $field): array
156156

157157
return $mapped;
158158
}
159-
160-
// TODO: We do not have anything like this
159+
161160
private function mapButtonGroup(array $field): array
162161
{
163-
$mapped = $this->mapBasic($field, 'buttonGroup');
164-
$mapped['type'] = 'radio';
165-
166-
$mapped['choices'] = [];
167-
foreach ($field['choices'] as $key => $value) {
168-
$mapped['choices'][$key] = [
169-
'type' => $mapped['type'],
170-
'label' => $value,
171-
'required' => $mapped['required'] ?? false,
172-
'name' => $field['key'],
173-
'value' => $key,
174-
'checked' => ($field['default_value'] ?? '') === $key,
175-
];
176-
}
177-
178-
return $mapped;
162+
return $this->mapRadio($field);
179163
}
180164

181165
private function mapTimePicker(array $field): array
@@ -269,31 +253,15 @@ private function mapEmail(array $field): array
269253

270254
private function mapTrueFalse(array $field): array
271255
{
272-
$mapped = $this->mapBasic($field, 'trueFalse');
273-
274-
$mapped['checked'] = !empty($field['default_value']) ? true : false;
275-
$mapped['type'] = 'radio';
276-
$mapped['attributeList']['role'] = 'radiogroup';
277-
$mapped['attributeList']['style'] = 'display: flex;';
278256

279-
$mapped['choices'] = [
280-
[
281-
'type' => $mapped['type'],
282-
'label' => __('No', 'modularity-frontend-form'),
283-
'name' => $field['key'],
284-
'value' => false,
285-
'checked' => !$mapped['checked'],
286-
],
287-
[
288-
'type' => $mapped['type'],
289-
'label' => __('Yes', 'modularity-frontend-form'),
290-
'required' => $mapped['required'] ?? false,
291-
'name' => $field['key'],
292-
'value' => true,
293-
'checked' => $mapped['checked'],
294-
],
257+
$field['choices'] = [
258+
0 => __('No', 'modularity-frontend-form'),
259+
1 => __('Yes', 'modularity-frontend-form'),
295260
];
296261

262+
$mapped = $this->mapRadio($field);
263+
264+
$mapped['attributeList']['style'] = 'display: flex;';
297265

298266
return $mapped;
299267
}

source/php/Module/views/fields/buttonGroup.blade.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

source/php/Module/views/fields/trueFalse.blade.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)