Skip to content

Commit 4eed660

Browse files
committed
Changed the form style to not affect layout.
1 parent a040c9a commit 4eed660

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

cake/libs/view/helpers/form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ public function button($title, $options = array()) {
12791279
* @return string A HTML button tag.
12801280
*/
12811281
public function postButton($title, $url, $options = array()) {
1282-
$out = $this->create(false, array('id' => false, 'url' => $url));
1282+
$out = $this->create(false, array('id' => false, 'url' => $url, 'style' => 'display:none;'));
12831283
if (isset($options['data']) && is_array($options['data'])) {
12841284
foreach ($options['data'] as $key => $value) {
12851285
$out .= $this->hidden($key, array('value' => $value, 'id' => false));
@@ -1315,7 +1315,7 @@ public function postLink($title, $url = null, $options = array(), $confirmMessag
13151315
}
13161316

13171317
$formName = uniqid('post_');
1318-
$out = $this->create(false, array('url' => $url, 'name' => $formName, 'id' => $formName));
1318+
$out = $this->create(false, array('url' => $url, 'name' => $formName, 'id' => $formName, 'style' => 'display:none;'));
13191319
if (isset($options['data']) && is_array($options['data'])) {
13201320
foreach ($options['data'] as $key => $value) {
13211321
$out .= $this->hidden($key, array('value' => $value, 'id' => false));

cake/tests/cases/libs/view/helpers/form.test.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5162,7 +5162,7 @@ function testButton() {
51625162
public function testPostButton() {
51635163
$result = $this->Form->postButton('Hi', '/controller/action');
51645164
$this->assertTags($result, array(
5165-
'form' => array('method' => 'post', 'action' => '/controller/action', 'accept-charset' => 'utf-8'),
5165+
'form' => array('method' => 'post', 'action' => '/controller/action', 'accept-charset' => 'utf-8', 'style' => 'display:none;'),
51665166
'div' => array('style' => 'display:none;'),
51675167
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
51685168
'/div',
@@ -5184,7 +5184,10 @@ public function testPostButton() {
51845184
public function testPostLink() {
51855185
$result = $this->Form->postLink('Delete', '/posts/delete/1');
51865186
$this->assertTags($result, array(
5187-
'form' => array('method' => 'post', 'action' => '/posts/delete/1', 'accept-charset' => 'utf-8', 'name' => 'preg:/post_\w+/', 'id' => 'preg:/post_\w+/'),
5187+
'form' => array(
5188+
'method' => 'post', 'action' => '/posts/delete/1', 'accept-charset' => 'utf-8',
5189+
'name' => 'preg:/post_\w+/', 'id' => 'preg:/post_\w+/', 'style' => 'display:none;'
5190+
),
51885191
'div' => array('style' => 'display:none;'),
51895192
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
51905193
'/div',
@@ -5196,7 +5199,10 @@ public function testPostLink() {
51965199

51975200
$result = $this->Form->postLink('Delete', '/posts/delete/1', array(), 'Confirm?');
51985201
$this->assertTags($result, array(
5199-
'form' => array('method' => 'post', 'action' => '/posts/delete/1', 'accept-charset' => 'utf-8', 'name' => 'preg:/post_\w+/', 'id' => 'preg:/post_\w+/'),
5202+
'form' => array(
5203+
'method' => 'post', 'action' => '/posts/delete/1', 'accept-charset' => 'utf-8',
5204+
'name' => 'preg:/post_\w+/', 'id' => 'preg:/post_\w+/', 'style' => 'display:none;'
5205+
),
52005206
'div' => array('style' => 'display:none;'),
52015207
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
52025208
'/div',

0 commit comments

Comments
 (0)