style input radios with bootstrap classes

This commit is contained in:
Thomas Rupprecht 2022-11-30 00:43:30 +01:00 committed by Igor Scheller
parent 0002585de4
commit 4ccceb271c
2 changed files with 17 additions and 11 deletions

View File

@ -196,9 +196,10 @@ function form_checkbox($name, $label, $selected, $value = 'checked', $html_id =
*/ */
function form_radio($name, $label, $selected, $value) function form_radio($name, $label, $selected, $value)
{ {
return '<div class="radio">' return '<div class="form-check">'
. '<label><input type="radio" id="' . $name . '" name="' . $name . '" value="' . htmlspecialchars((string)$value) . '" ' . '<input class="form-check-input" type="radio" id="' . $name . '" name="' . $name . '" value="' . htmlspecialchars((string)$value) . '" '
. ($selected ? ' checked="checked"' : '') . ' />' . ($selected ? ' checked="checked"' : '') . ' />'
. '<label class="form-check-label" for="' . $name . '">'
. $label . $label
. '</label></div>'; . '</label></div>';
} }
@ -478,8 +479,11 @@ function html_options($name, $options, $selected = '')
{ {
$html = ''; $html = '';
foreach ($options as $value => $label) { foreach ($options as $value => $label) {
$html .= '<input type="radio"' . ($value == $selected ? ' checked="checked"' : '') . ' name="' $html .= '<div class="form-check form-check-inline">'
. $name . '" value="' . $value . '"> ' . $label; . '<input class="form-check-input" type="radio" id="' . $name . '_' . $value . '" name="' . $name . '"'
. ($value == $selected ? ' checked="checked"' : '') . ' value="' . $value . '" />'
. '<label class="form-check-label" for="' . $name . '_' . $value . '">' . $label . '</label>'
. '</div>';
} }
return $html; return $html;

View File

@ -259,12 +259,14 @@
</div> </div>
<div class="col-md-3 col-lg-2 checkbox-inline"> <div class="col-md-3 col-lg-2 checkbox-inline">
Radio<br> Radio<br>
<label> <div class="form-check form-check-inline">
<input type="radio" checked="checked" name="form-input-radio" value="1"> Yey <input class="form-check-input" type="radio" id="yey" checked="checked" name="form-input-radio" value="1">
</label> <label class="form-check-label" for="yey">Yey</label>
<label> </div>
<input type="radio" name="form-input-radio"> Nay <div class="form-check form-check-inline">
</label> <input class="form-check-input" type="radio" id="nay" name="form-input-radio">
<label class="form-check-label" for="nay">Nay</label>
</div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">