Skip to content

Commit

Permalink
Properly align grouped html controls
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Mar 12, 2024
1 parent 58a6cd3 commit da9819a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
31 changes: 14 additions & 17 deletions app/src/View/Helper/FieldHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,10 @@ protected function formInfoDiv(string $content,
}

/**
* Generate a form info (control, value) box.
* Create grouped control elements. By default, the elements will be placed one after the other, inline,
* with a direction left to right. For that need to occupy the whole row we defined the 'singleRowItem'
* configuration property that will add an inline Bootstrap css rule. The rule will override the default
* behavior
*
* @param array $fields
* @param string $pseudoFieldName
Expand All @@ -397,24 +400,18 @@ protected function formInfoDiv(string $content,
* @since COmanage Registry v5.0.0
*/

public function formInfoWithMultipleControls(array $fields,
string $pseudoFieldName,
string $beforeField = '',
string $afterField = ''): string {
public function groupedControls(array $fields,
string $pseudoFieldName,
string $beforeField = '',
string $afterField = ''): string {
$content = '';
foreach ($fields as $fieldName => $fieldOptions) {
if(isset($fieldOptions['type'])
&& $fieldOptions['type'] == 'checkbox') {
$content .= '<div class="checkbox">' . PHP_EOL;
$content .= $this->formControl($fieldName) . PHP_EOL;
$content .= '</div>' . PHP_EOL;
} else {
$content .= '<div class="subfield subfield-cols">' . PHP_EOL;
$content .= '<div class="field-col">' . PHP_EOL;
$content .= $this->formControl($fieldName, $fieldOptions['options'] ?? []) . PHP_EOL;
$content .= '</div>' . PHP_EOL;
$content .= '</div>' . PHP_EOL;
}
$dblock = isset($fieldOptions['singleRowItem']) && $fieldOptions['singleRowItem'] ? 'd-block' : '';
$content .= "<div class='subfield subfield-cols {$dblock}'>" . PHP_EOL;
$content .= '<div class="field-col">' . PHP_EOL;
$content .= $this->formControl($fieldName, $fieldOptions['options'] ?? []) . PHP_EOL;
$content .= '</div>' . PHP_EOL;
$content .= '</div>' . PHP_EOL;
}
$mn = $this->modelName;

Expand Down
6 changes: 3 additions & 3 deletions app/templates/CoSettings/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if($vv_action == 'edit') {

print $this->Field->control('search_global_limited_models');

print $this->Field->formInfoWithMultipleControls(
print $this->Field->groupedControls(
[
'person_picker_email_address_type_id' => [
'options' => [
Expand All @@ -69,8 +69,8 @@ if($vv_action == 'edit') {
],
],
'person_picker_display_types' => [
'type' => 'checkbox'
],
'singleRowItem' => true
]
],
'person_picker_display_fields'
);
Expand Down

0 comments on commit da9819a

Please sign in to comment.