Commit 26191b6b authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

Added a textarea form element renderer.

parent d98a825b
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage core or plugintype/pluginname
* @author Your Name <you@example.org>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
function form_render_textarea($element, $form) {
$rows = $cols = $style = '';
if (isset($element['height'])) {
$style .= 'height:' . $element['height'] . ';';
$rows = (intval($element['height'] > 0)) ? ceil(intval($element['height']) / 10) : 1;
}
elseif (isset($element['rows'])) {
$rows = $element['rows'];
}
else {
log_warn('No value for rows or height specified for textarea ' . $element['name']);
}
if (isset($element['width'])) {
$style .= 'width:' . $element['width'] . ';';
$cols = (intval($element['width'] > 0)) ? ceil(intval($element['width']) / 10) : 1;
}
elseif (isset($element['cols'])) {
$cols = $element['cols'];
}
else {
log_warn('No value for cols or width specified for textarea ' . $element['name']);
}
$element['style'] = (isset($element['style'])) ? $style . $element['style'] : $style;
return '<textarea'
. (($rows) ? ' rows="' . $rows . '"' : '')
. (($cols) ? ' cols="' . $cols . '"' : '')
. Form::element_attributes($element, array('maxlength', 'size'))
. '>' . hsc($form->get_value($element)) . '</textarea>';
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment