Skip to content

Improve label handling for checkboxes (CFM-446, CFM-403) #278

Merged
merged 2 commits into from Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/resources/locales/en_US/field.po
Expand Up @@ -496,10 +496,10 @@ msgid "Groups.group_type"
msgstr "Group Type"

msgid "Groups.nesting_mode_all"
msgstr "Require All for Nested Memberships"
msgstr "Nesting Mode: All"

msgid "Groups.nesting_mode_all.desc"
msgstr "When enabled, a Person must be found in ALL nested groups to be included as a member. When disabled, a Person found in ANY nested group will be included. (Note that People in negated nested groups are always excluded.)"
msgstr "When checked, a Person must be found in ALL nested groups to be included as a member of this group. Otherwise, a Person found in ANY nested group will be included."

msgid "Groups.open"
msgstr "Open"
Expand Down
7 changes: 7 additions & 0 deletions app/src/View/Helper/FieldHelper.php
Expand Up @@ -443,6 +443,13 @@ public function formField(string $fieldName,
if(empty($fieldSelectOptions) && $fieldType === 'select') {
$fieldType = '';
}

// Checkbox labels need special handling
if($fieldType == 'boolean') {
[$cbLabel] = $this->calculateLabelAndDescription($fieldName);
$fieldLabel = $fieldLabel ?? $cbLabel;
}

// Generate the form control or pass along the markup generated in a wrapper function
return match($fieldType) {
// A boolean field is a checkbox. Set the label and class to improve rendering
Expand Down
9 changes: 2 additions & 7 deletions app/templates/Groups/fields.inc
Expand Up @@ -35,7 +35,8 @@ if($vv_obj->isOwners()) {
foreach(['name',
'description',
'status',
'open',] as $field) {
'open',
'nesting_mode_all'] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field,
Expand All @@ -44,12 +45,6 @@ foreach(['name',
]);
}

print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'nesting_mode_all',
]
]);

if($vv_action != 'add') {
print $this->element('form/listItem', [
'arguments' => [
Expand Down
6 changes: 5 additions & 1 deletion app/webroot/css/co-base.css
Expand Up @@ -1595,8 +1595,12 @@ ul.form-list .field-suppliment {
ul.form-list li.info-title {
border: none;
}
.checkbox label input {
.checkbox label input[type="checkbox"] {
position: relative;
top: -0.12em;
margin-right: 0.5em;
width: 1.24em;
height: 1.24em;
}
.checkbox .subfield {
margin-left: 1.5em;
Expand Down