Skip to content

Commit

Permalink
Fix input submit via magic input method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Scherer committed Apr 21, 2015
1 parent def326c commit c126e61
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/View/Helper/FormHelper.php
Expand Up @@ -1012,6 +1012,7 @@ public function input($fieldName, array $options = [])

$label = $options['label'];
unset($options['label']);

$nestedInput = false;
if ($options['type'] === 'checkbox') {
$nestedInput = true;
Expand All @@ -1023,7 +1024,7 @@ public function input($fieldName, array $options = [])
}

$input = $this->_getInput($fieldName, $options);
if ($options['type'] === 'hidden') {
if ($options['type'] === 'hidden' || $options['type'] === 'submit') {
if ($newTemplates) {
$templater->pop();
}
Expand Down
18 changes: 18 additions & 0 deletions tests/TestCase/View/Helper/FormHelperTest.php
Expand Up @@ -3120,6 +3120,24 @@ public function testInputMagicSelectChangeToRadio()
$this->assertContains('input type="radio"', $result);
}

/**
* testFormInputSubmit method
*
* test correct results for form::input() and type submit.
*
* @return void
*/
public function testFormInputSubmit()
{
$result = $this->Form->input('Test Submit', ['type' => 'submit', 'class' => 'foobar']);
$expected = [
'div' => ['class' => 'submit'],
'input' => ['type' => 'submit', 'class' => 'foobar', 'id' => 'test-submit', 'value' => 'Test Submit'],
'/div'
];
$this->assertHtml($expected, $result);
}

/**
* testFormInputs method
*
Expand Down

0 comments on commit c126e61

Please sign in to comment.