Skip to content

Commit

Permalink
[#8] Fix conditions for deciding whether "Select" fields are to be di…
Browse files Browse the repository at this point in the history
…splayed as radio buttons or checkboxes
  • Loading branch information
jensschuppe committed Feb 20, 2024
1 parent cbde9e8 commit fd924a0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions modules/civiremote_event/src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,23 @@ public static function fieldType($field, $step = 'form') {
if (isset($field['validation']) && $field['validation'] == 'Email') {
$type = 'email';
}
// Use radio buttons for select fields with up to 10 options.
// Use checkboxes for multi-select fields with up to 10 options.
elseif (
$types[$field['type']] == 'select'
&& count($field['options']) <= 10
// Checkboxes #options may not have a 0 key.
&& !isset($field['options'][0])
&& $field['type'] == 'Multi-Select'
) {
$type = $field['type'] == 'Multi-Select' ? 'checkboxes' : 'radios';
$type = 'checkboxes';
}
// Use radio buttons for single-select fields with up to 10 options.
elseif (
$types[$field['type']] == 'select'
&& count($field['options']) <= 10
&& $field['type'] != 'Multi-Select'
) {
$type = 'radios';
}
// Use details element for session fieldsets.
elseif (
Expand Down

0 comments on commit fd924a0

Please sign in to comment.