public function textarea()
{
return _class('html')->textarea('input_name', 'some value');
}
public function textarea($name = '', $value = '', $extra = [])
{
if (is_array($name)) {
$extra = (array) $extra + $name;
$name = $extra['name'];
}
if ( ! is_array($extra)) {
$extra = [];
}
$extra['name'] = $extra['name'] ?: ($name ?: 'text');
$extra['value'] = $extra['value'] ?: $value;
$extra['id'] = $extra['id'] ?: __FUNCTION__ . '_' . ++$this->_ids[__FUNCTION__];
$extra['desc'] = $extra['desc'] ?: ucfirst(str_replace('_', '', $extra['name']));
$extra['type'] = $extra['type'] ?: 'text';
$extra['placeholder'] = $extra['placeholder'] ? t($extra['placeholder']) : $extra['desc'];
$extra['contenteditable'] = ( ! isset($extra['contenteditable']) || $extra['contenteditable']) ? 'true' : false;
$attrs_names = ['id', 'name', 'placeholder', 'contenteditable', 'class', 'style', 'cols', 'rows', 'title', 'required', 'size', 'disabled', 'readonly', 'autocomplete', 'autofocus'];
return '<textarea' . _attrs($extra, $attrs_names) . '>' . ( ! isset($extra['no_escape']) ? _htmlchars($extra['value']) : $extra['value']) . '</textarea>';
}