Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Hidden divs created by FormHelper can now be customized.

  • Loading branch information...
commit 28951865c66e84efdb20065a13ecadf51cf0c0f1 1 parent 771cfde
@ADmad ADmad authored
View
24 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -792,14 +792,32 @@ public function testFormSecurityFields() {
$this->Form->request['_Token'] = array('key' => $key);
$result = $this->Form->secure($fields);
- $expected = Security::hash(serialize($fields) . Configure::read('Security.salt'));
- $expected .= ':' . 'Model.valid';
+ $hash = Security::hash(serialize($fields) . Configure::read('Security.salt'));
+ $hash .= ':' . 'Model.valid';
+ $hash = urlencode($hash);
$expected = array(
'div' => array('style' => 'display:none;'),
array('input' => array(
'type' => 'hidden', 'name' => 'data[_Token][fields]',
- 'value' => urlencode($expected), 'id' => 'preg:/TokenFields\d+/'
+ 'value' => $hash, 'id' => 'preg:/TokenFields\d+/'
+ )),
+ array('input' => array(
+ 'type' => 'hidden', 'name' => 'data[_Token][unlocked]',
+ 'value' => '', 'id' => 'preg:/TokenUnlocked\d+/'
+ )),
+ '/div'
+ );
+ $this->assertTags($result, $expected);
+
+ $path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS;
+ $this->Form->Html->loadConfig('htmlhelper_tags', $path);
+ $result = $this->Form->secure($fields);
+ $expected = array(
+ 'div' => array('class' => 'hidden'),
+ array('input' => array(
+ 'type' => 'hidden', 'name' => 'data[_Token][fields]',
+ 'value' => $hash, 'id' => 'preg:/TokenFields\d+/'
)),
array('input' => array(
'type' => 'hidden', 'name' => 'data[_Token][unlocked]',
View
3  lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php
@@ -1863,7 +1863,8 @@ public function testLoadConfig() {
$expected = array(
'tags' => array(
'form' => 'start form',
- 'formend' => 'finish form'
+ 'formend' => 'finish form',
+ 'hiddenblock' => '<div class="hidden">%s</div>'
)
);
$this->assertEquals($expected, $result);
View
3  lib/Cake/Test/test_app/Config/htmlhelper_tags.php
@@ -3,6 +3,7 @@
$config = array(
'tags' => array(
'form' => 'start form',
- 'formend' => 'finish form'
+ 'formend' => 'finish form',
+ 'hiddenblock' => '<div class="hidden">%s</div>'
)
);
View
4 lib/Cake/View/Helper/FormHelper.php
@@ -428,7 +428,7 @@ public function create($model = null, $options = array()) {
$append .= $this->_csrfField();
if (!empty($append)) {
- $append = $this->Html->useTag('block', ' style="display:none;"', $append);
+ $append = $this->Html->useTag('hiddenblock', $append);
}
if ($model !== false) {
@@ -545,7 +545,7 @@ public function secure($fields = array()) {
'value' => urlencode($unlocked),
'id' => 'TokenUnlocked' . mt_rand()
));
- return $this->Html->useTag('block', ' style="display:none;"', $out);
+ return $this->Html->useTag('hiddenblock', $out);
}
/**
View
1  lib/Cake/View/Helper/HtmlHelper.php
@@ -78,6 +78,7 @@ class HtmlHelper extends AppHelper {
'block' => '<div%s>%s</div>',
'blockstart' => '<div%s>',
'blockend' => '</div>',
+ 'hiddenblock' => '<div style="display:none;">%s</div>',
'tag' => '<%s%s>%s</%s>',
'tagstart' => '<%s%s>',
'tagend' => '</%s>',
Please sign in to comment.
Something went wrong with that request. Please try again.