Skip to content

Commit

Permalink
Improve label handling for checkboxes (CFM-446, CFM-403) (#278)
Browse files Browse the repository at this point in the history
* Improve label handling for checkboxes (CFM-446, CFM-403)

* Update "Require all for nested group" label and description (CFM-446, CFM-403)
  • Loading branch information
arlen authored Feb 4, 2025
1 parent 16c023e commit 650dfc9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/resources/locales/en_US/field.po
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 650dfc9

Please sign in to comment.