Fix invisible buttons.

Fixes #2802
This commit is contained in:
mark_story 2012-04-17 20:46:19 -04:00
parent e54e494b4b
commit 94e83fa81c
2 changed files with 3 additions and 4 deletions

View file

@ -5974,7 +5974,7 @@ class FormHelperTest extends CakeTestCase {
public function testPostButton() {
$result = $this->Form->postButton('Hi', '/controller/action');
$this->assertTags($result, array(
'form' => array('method' => 'post', 'action' => '/controller/action', 'accept-charset' => 'utf-8', 'style' => 'display:none;'),
'form' => array('method' => 'post', 'action' => '/controller/action', 'accept-charset' => 'utf-8'),
'div' => array('style' => 'display:none;'),
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
'/div',
@ -6000,7 +6000,6 @@ class FormHelperTest extends CakeTestCase {
$expected = array(
'form' => array(
'method' => 'post', 'action' => '/posts/delete/1', 'accept-charset' => 'utf-8',
'style' => 'display:none;'
),
array('div' => array('style' => 'display:none;')),
array('input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST')),

View file

@ -1545,7 +1545,7 @@ class FormHelper extends AppHelper {
/**
* Create a `<button>` tag with a surrounding `<form>` that submits via POST.
*
* This method creates a `<form>` element. So do not use this method in some opened form.
* This method creates a `<form>` element. So do not use this method in an already opened form.
* Instead use FormHelper::submit() or FormHelper::button() to create buttons inside opened forms.
*
* ### Options:
@ -1560,7 +1560,7 @@ class FormHelper extends AppHelper {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::postButton
*/
public function postButton($title, $url, $options = array()) {
$out = $this->create(false, array('id' => false, 'url' => $url, 'style' => 'display:none;'));
$out = $this->create(false, array('id' => false, 'url' => $url));
if (isset($options['data']) && is_array($options['data'])) {
foreach ($options['data'] as $key => $value) {
$out .= $this->hidden($key, array('value' => $value, 'id' => false));