From 4f53c301a84e60ab091324919a1c0ca453f421e2 Mon Sep 17 00:00:00 2001 From: nate Date: Tue, 22 Aug 2006 19:35:08 +0000 Subject: [PATCH] Fixing URLs in HtmlHelper::meta(), and moving textarea() to FormHelper git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3427 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/view/helpers/form.php | 28 +++++++++++++++++++++++++++- cake/libs/view/helpers/html.php | 2 +- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 98b83dcfa..c906d6b67 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -139,7 +139,7 @@ class FormHelper extends Helper { $this->Html->setFormTag($fieldName); if (!isset($htmlAttributes['value'])) { - $htmlAttributes['value'] = $this->tagValue($fieldName); + $htmlAttributes['value'] = $this->Html->tagValue($fieldName); } if (!isset($htmlAttributes['type'])) { @@ -160,6 +160,32 @@ class FormHelper extends Helper { return sprintf($this->tags['input'], $this->Html->model, $this->Html->field, $this->Html->_parseAttributes($htmlAttributes, null, ' ', ' ')); } +/** + * Creates a textarea widget. + * + * @param string $fieldNamem Name of a field, like this "Modelname/fieldname" + * @param array $htmlAttributes Array of HTML attributes. + * @return string An HTML text input element + */ + function textarea($fieldName, $htmlAttributes = null) { + $value = $this->Html->tagValue($fieldName); + if (!empty($htmlAttributes['value'])) { + $value = $htmlAttributes['value']; + unset($htmlAttributes['value']); + } + if (!isset($htmlAttributes['id'])) { + $htmlAttributes['id'] = $this->Html->model . Inflector::camelize($this->Html->field); + } + + if ($this->Html->tagIsInvalid($this->Html->model, $this->Html->field)) { + if (isset($htmlAttributes['class']) && trim($htmlAttributes['class']) != "") { + $htmlAttributes['class'] .= ' form_error'; + } else { + $htmlAttributes['class'] = 'form_error'; + } + } + return $this->output(sprintf($this->tags['textarea'], $this->Html->model, $this->Html->field, $this->Html->_parseAttributes($htmlAttributes, null, ' '), $value)); + } /** * Creates a button tag. * diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index 7f5559ac2..c4096d52c 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -168,7 +168,7 @@ class HtmlHelper extends Helper { if (!isset($attributes['rel'])) { $attributes['rel'] = 'alternate'; } - return $this->output(sprintf($this->tags['metalink'], $this->url($url), $title, $this->_parseAttributes($attributes))); + return $this->output(sprintf($this->tags['metalink'], $this->url($url, true), $title, $this->_parseAttributes($attributes))); } /** * Returns a charset META-tag.