rooms admin: Set a maximum character length

closes #525 (Room names with more than 35 characters dispatch a team of untrained monkeys)
main
Igor Scheller 6 years ago
parent c676e73cf6
commit 204ff4c0e7

@ -158,7 +158,7 @@ function admin_rooms()
form([ form([
div('row', [ div('row', [
div('col-md-6', [ div('col-md-6', [
form_text('name', __('Name'), $name), form_text('name', __('Name'), $name, false, 35),
form_checkbox('from_frab', __('Frab import'), $from_frab), form_checkbox('from_frab', __('Frab import'), $from_frab),
form_text('map_url', __('Map URL'), $map_url), form_text('map_url', __('Map URL'), $map_url),
form_info('', __('The map url is used to display an iframe on the room page.')), form_info('', __('The map url is used to display an iframe on the room page.')),

@ -229,15 +229,18 @@ function form_submit($name, $label, $class = '', $wrapForm = true, $buttonType =
* @param string $label * @param string $label
* @param string $value * @param string $value
* @param bool $disabled * @param bool $disabled
* @param int $maxlength
* @return string * @return string
*/ */
function form_text($name, $label, $value, $disabled = false) function form_text($name, $label, $value, $disabled = false, $maxlength = null)
{ {
$disabled = $disabled ? ' disabled="disabled"' : ''; $disabled = $disabled ? ' disabled="disabled"' : '';
$maxlength = $maxlength ? ' maxlength=' . (int)$maxlength : '';
return form_element( return form_element(
$label, $label,
'<input class="form-control" id="form_' . $name . '" type="text" name="' . $name '<input class="form-control" id="form_' . $name . '" type="text" name="' . $name
. '" value="' . htmlspecialchars($value) . '" ' . $disabled . '/>', . '" value="' . htmlspecialchars($value) . '"' . $maxlength . $disabled . '/>',
'form_' . $name 'form_' . $name
); );
} }

Loading…
Cancel
Save