From 69da631d612ba58f0b6d50e616f98883c72783b4 Mon Sep 17 00:00:00 2001 From: phpnut Date: Thu, 5 Apr 2007 21:20:08 +0000 Subject: [PATCH] Adding fix for Ticket #2353 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4795 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/view/helpers/form.php | 22 ++++++++++++---------- cake/libs/view/helpers/html.php | 8 +++++--- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 03664f903..d334845f2 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -57,9 +57,9 @@ class FormHelper extends AppHelper { var $helpers = array('Html'); - + /** - * holds the fields array('field_name'=>'type'), sizes array('field_name'=>'size'), + * holds the fields array('field_name'=>'type'), sizes array('field_name'=>'size'), * primaryKey and validates array('field_name') * * @access public @@ -188,7 +188,9 @@ class FormHelper extends AppHelper { $htmlAttributes = am($options, $htmlAttributes); if (isset($this->params['_Token']) && !empty($this->params['_Token'])) { - $append .= $this->hidden('_Token/key', array('value' => $this->params['_Token']['key'], 'id' => $options['id'] . 'Token')); + $append .= '

'; + $append .= $this->hidden('_Token/key', array('value' => $this->params['_Token']['key'], 'id' => $options['id'] . 'Token' . mt_rand())); + $append .= '

'; } $this->setFormTag($model . '.'); @@ -287,8 +289,8 @@ class FormHelper extends AppHelper { function inputs($fields = null, $blacklist = null) { if(!is_array($fields)) { $fields = array_keys($this->fieldset['fields']); - } - + } + $out = null; foreach($fields as $name => $options) { if(is_array($blacklist) && in_array($name, $blacklist)) { @@ -378,9 +380,9 @@ class FormHelper extends AppHelper { $div = $options['div']; unset($options['div']); } - + if(!empty($div)) { - $divOptions = array('class'=>'input'); + $divOptions = array('class'=>'input'); if (is_string($div)) { $divOptions['class'] = $div; } elseif (is_array($div)) { @@ -388,9 +390,9 @@ class FormHelper extends AppHelper { } if (in_array($this->field(), $this->fieldset['validates'])) { $divOptions = $this->addClass($divOptions, 'required'); - } + } } - + $label = null; if (isset($options['label'])) { $label = $options['label']; @@ -1338,4 +1340,4 @@ class FormHelper extends AppHelper { } } -?> \ No newline at end of file +?> diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index f3a2a8c46..690978e41 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -709,13 +709,15 @@ class HtmlHelper extends AppHelper { $htmlAttributes['action'] = $this->url($target); $htmlAttributes['method'] = low($type) == 'get' ? 'get' : 'post'; $type == 'file' ? $htmlAttributes['enctype'] = 'multipart/form-data' : null; - $token = ''; + $append = ''; if (isset($this->params['_Token']) && !empty($this->params['_Token'])) { - $token = $this->hidden('_Token/key', array('value' => $this->params['_Token']['key']), true); + $append .= '

'; + $append .= $this->hidden('_Token/key', array('value' => $this->params['_Token']['key'], 'id' => '_TokenKey' . mt_rand()), true); + $append .= '

'; } - return sprintf($this->tags['form'], $this->parseHtmlOptions($htmlAttributes, null, '')) . $token; + return sprintf($this->tags['form'], $this->parseHtmlOptions($htmlAttributes, null, '')) . $append; } /** * @deprecated