mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Hidden divs created by FormHelper can now be customized.
This commit is contained in:
parent
771cfde196
commit
28951865c6
5 changed files with 28 additions and 7 deletions
|
@ -792,14 +792,32 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->Form->request['_Token'] = array('key' => $key);
|
$this->Form->request['_Token'] = array('key' => $key);
|
||||||
$result = $this->Form->secure($fields);
|
$result = $this->Form->secure($fields);
|
||||||
|
|
||||||
$expected = Security::hash(serialize($fields) . Configure::read('Security.salt'));
|
$hash = Security::hash(serialize($fields) . Configure::read('Security.salt'));
|
||||||
$expected .= ':' . 'Model.valid';
|
$hash .= ':' . 'Model.valid';
|
||||||
|
$hash = urlencode($hash);
|
||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'div' => array('style' => 'display:none;'),
|
'div' => array('style' => 'display:none;'),
|
||||||
array('input' => array(
|
array('input' => array(
|
||||||
'type' => 'hidden', 'name' => 'data[_Token][fields]',
|
'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(
|
array('input' => array(
|
||||||
'type' => 'hidden', 'name' => 'data[_Token][unlocked]',
|
'type' => 'hidden', 'name' => 'data[_Token][unlocked]',
|
||||||
|
|
|
@ -1863,7 +1863,8 @@ class HtmlHelperTest extends CakeTestCase {
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'tags' => array(
|
'tags' => array(
|
||||||
'form' => 'start form',
|
'form' => 'start form',
|
||||||
'formend' => 'finish form'
|
'formend' => 'finish form',
|
||||||
|
'hiddenblock' => '<div class="hidden">%s</div>'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
$config = array(
|
$config = array(
|
||||||
'tags' => array(
|
'tags' => array(
|
||||||
'form' => 'start form',
|
'form' => 'start form',
|
||||||
'formend' => 'finish form'
|
'formend' => 'finish form',
|
||||||
|
'hiddenblock' => '<div class="hidden">%s</div>'
|
||||||
)
|
)
|
||||||
);
|
);
|
|
@ -428,7 +428,7 @@ class FormHelper extends AppHelper {
|
||||||
$append .= $this->_csrfField();
|
$append .= $this->_csrfField();
|
||||||
|
|
||||||
if (!empty($append)) {
|
if (!empty($append)) {
|
||||||
$append = $this->Html->useTag('block', ' style="display:none;"', $append);
|
$append = $this->Html->useTag('hiddenblock', $append);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($model !== false) {
|
if ($model !== false) {
|
||||||
|
@ -545,7 +545,7 @@ class FormHelper extends AppHelper {
|
||||||
'value' => urlencode($unlocked),
|
'value' => urlencode($unlocked),
|
||||||
'id' => 'TokenUnlocked' . mt_rand()
|
'id' => 'TokenUnlocked' . mt_rand()
|
||||||
));
|
));
|
||||||
return $this->Html->useTag('block', ' style="display:none;"', $out);
|
return $this->Html->useTag('hiddenblock', $out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -78,6 +78,7 @@ class HtmlHelper extends AppHelper {
|
||||||
'block' => '<div%s>%s</div>',
|
'block' => '<div%s>%s</div>',
|
||||||
'blockstart' => '<div%s>',
|
'blockstart' => '<div%s>',
|
||||||
'blockend' => '</div>',
|
'blockend' => '</div>',
|
||||||
|
'hiddenblock' => '<div style="display:none;">%s</div>',
|
||||||
'tag' => '<%s%s>%s</%s>',
|
'tag' => '<%s%s>%s</%s>',
|
||||||
'tagstart' => '<%s%s>',
|
'tagstart' => '<%s%s>',
|
||||||
'tagend' => '</%s>',
|
'tagend' => '</%s>',
|
||||||
|
|
Loading…
Reference in a new issue