style checkboxes with bootstrap classes

This commit is contained in:
Thomas Rupprecht 2022-11-30 00:14:08 +01:00 committed by Igor Scheller
parent 0a1014496a
commit e8ccbd7c5e
4 changed files with 17 additions and 15 deletions

View File

@ -147,16 +147,17 @@ function admin_user()
. page_link_to('admin_user', ['action' => 'save_groups', 'id' => $user_id])
. '" method="post">' . "\n";
$html .= form_csrf();
$html .= '<table>';
$html .= '<div>';
$groups = changeableGroups($my_highest_group, $user_id);
foreach ($groups as $group) {
$html .= '<tr><td><input type="checkbox" name="groups[]" value="' . $group->id . '" '
$html .= '<div class="form-check">'
. '<input class="form-check-input" type="checkbox" id="' . $group->id . '" name="groups[]" value="' . $group->id . '" '
. ($group->selected ? ' checked="checked"' : '')
. ' /></td><td>' . $group->name . '</td></tr>';
. ' /><label class="form-check-label" for="' . $group->id . '">' . $group->name . '</label></div>';
}
$html .= '</table><br>';
$html .= '</div><br>';
$html .= '<input type="submit" value="Speichern" class="btn btn-primary">' . "\n";
$html .= '</form>';

View File

@ -372,10 +372,11 @@ function make_select($items, $selected, $name, $title = null, $additionalButtons
$html .= buttons($buttons);
foreach ($items as $i) {
$htmlItems[] = '<div class="checkbox">'
. '<label><input type="checkbox" name="' . $name . '[]" value="' . $i['id'] . '" '
$id = $name . '_' . $i['id'];
$htmlItems[] = '<div class="form-check">'
. '<input class="form-check-input" type="checkbox" id="' . $id . '" name="' . $name . '[]" value="' . $i['id'] . '" '
. (in_array($i['id'], $selected) ? ' checked="checked"' : '')
. ' > ' . $i['name'] . '</label>'
. ' /><label class="form-check-label" for="' . $id . '">' . $i['name'] . '</label>'
. (!isset($i['enabled']) || $i['enabled'] ? '' : icon('book'))
. '</div>';
}

View File

@ -175,9 +175,9 @@ function form_checkbox($name, $label, $selected, $value = 'checked', $html_id =
$html_id = $name;
}
return '<div class="checkbox"><label>'
. '<input type="checkbox" id="' . $html_id . '" name="' . $name . '" value="' . htmlspecialchars((string)$value) . '" '
. ($selected ? ' checked="checked"' : '') . ' /> '
return '<div class="form-check">'
. '<input class="form-check-input" type="checkbox" id="' . $html_id . '" name="' . $name . '" value="' . htmlspecialchars((string)$value) . '" '
. ($selected ? ' checked="checked"' : '') . ' /><label class="form-check-label" for="' . $html_id . '">'
. $label
. '</label></div>';
}

View File

@ -74,11 +74,11 @@
{% macro checkbox(name, label, checked, value, disabled, raw_label) %}
<div class="form-check mb-3">
<label>
<input type="checkbox" id="{{ name }}" name="{{ name }}" value="{{ value|default('1') }}" class="form-check-input"
{%- if checked|default(false) %} checked{% endif %}
{%- if disabled|default(false) %} disabled{% endif %}
>
<input class="form-check-input" type="checkbox" id="{{ name }}" name="{{ name }}" value="{{ value|default('1') }}"
{%- if checked|default(false) %} checked{% endif %}
{%- if disabled|default(false) %} disabled{% endif %}
/>
<label class="form-check-label" for="{{ name }}">
{%- if raw_label|default(false) -%}
{{ label|raw }}
{%- else -%}