From 204ff4c0e79fab0d1f73daa29a026582efffee69 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Tue, 18 Dec 2018 13:22:10 +0100 Subject: rooms admin: Set a maximum character length closes #525 (Room names with more than 35 characters dispatch a team of untrained monkeys) --- includes/pages/admin_rooms.php | 2 +- includes/sys_form.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/includes/pages/admin_rooms.php b/includes/pages/admin_rooms.php index 558145bc..bc0eb651 100644 --- a/includes/pages/admin_rooms.php +++ b/includes/pages/admin_rooms.php @@ -158,7 +158,7 @@ function admin_rooms() form([ div('row', [ 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_text('map_url', __('Map URL'), $map_url), form_info('', __('The map url is used to display an iframe on the room page.')), diff --git a/includes/sys_form.php b/includes/sys_form.php index 38e9da4e..af8d094a 100644 --- a/includes/sys_form.php +++ b/includes/sys_form.php @@ -229,15 +229,18 @@ function form_submit($name, $label, $class = '', $wrapForm = true, $buttonType = * @param string $label * @param string $value * @param bool $disabled + * @param int $maxlength * @return string */ -function form_text($name, $label, $value, $disabled = false) +function form_text($name, $label, $value, $disabled = false, $maxlength = null) { $disabled = $disabled ? ' disabled="disabled"' : ''; + $maxlength = $maxlength ? ' maxlength=' . (int)$maxlength : ''; + return form_element( $label, '', + . '" value="' . htmlspecialchars($value) . '"' . $maxlength . $disabled . '/>', 'form_' . $name ); } -- cgit v1.2.3-54-g00ecf