Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated FormHelper::end() to use new string template.

The method no longer generates submit button too.
  • Loading branch information...
commit 5662eaaa3bb1a11c9f0f888deeecd43ad171951c 1 parent 999429c
@ADmad ADmad authored
View
37 src/View/Helper/FormHelper.php
@@ -444,48 +444,21 @@ protected function _csrfField() {
* Closes an HTML form, cleans up values set by FormHelper::create(), and writes hidden
* input fields where appropriate.
*
- * If $options is set a form submit button will be created. Options can be either a string or an array.
- *
- * {{{
- * array usage:
- *
- * array('label' => 'save'); value="save"
- * array('label' => 'save', 'name' => 'Whatever'); value="save" name="Whatever"
- * array('name' => 'Whatever'); value="Submit" name="Whatever"
- * array('label' => 'save', 'name' => 'Whatever', 'div' => 'good') <div class="good"> value="save" name="Whatever"
- * array('label' => 'save', 'name' => 'Whatever', 'div' => array('class' => 'good')); <div class="good"> value="save" name="Whatever"
- * }}}
- *
- * @param string|array $options as a string will use $options as the value of button,
- * @return string a closing FORM tag optional submit button.
+ * @return string A closing FORM tag.
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#closing-the-form
*/
- public function end($options = null) {
- $out = null;
- $submit = null;
+ public function end() {
+ $out = '';
- if ($options !== null) {
- $submitOptions = array();
- if (is_string($options)) {
- $submit = $options;
- } else {
- if (isset($options['label'])) {
- $submit = $options['label'];
- unset($options['label']);
- }
- $submitOptions = $options;
- }
- $out .= $this->submit($submit, $submitOptions);
- }
if (
$this->requestType !== 'get' &&
- isset($this->request['_Token']) &&
!empty($this->request['_Token'])
) {
$out .= $this->secure($this->fields);
$this->fields = array();
}
- $out .= $this->Html->useTag('formend');
+
+ $out .= $this->formatTemplate('formend', []);
$this->requestType = null;
$this->_context = null;
View
75 tests/TestCase/View/Helper/FormHelperTest.php
@@ -8323,82 +8323,7 @@ public function testFormMagicInputLabel() {
* @return void
*/
public function testFormEnd() {
- $this->markTestIncomplete('Need to revisit once models work again.');
$this->assertEquals('</form>', $this->Form->end());
-
- $result = $this->Form->end('');
- $expected = array(
- 'div' => array('class' => 'submit'),
- 'input' => array('type' => 'submit', 'value' => ''),
- '/div',
- '/form'
- );
- $this->assertTags($result, $expected);
-
- $result = $this->Form->end(array('label' => ''));
- $expected = array(
- 'div' => array('class' => 'submit'),
- 'input' => array('type' => 'submit', 'value' => ''),
- '/div',
- '/form'
- );
- $this->assertTags($result, $expected);
-
- $result = $this->Form->end('save');
- $expected = array(
- 'div' => array('class' => 'submit'),
- 'input' => array('type' => 'submit', 'value' => 'save'),
- '/div',
- '/form'
- );
- $this->assertTags($result, $expected);
-
- $result = $this->Form->end(array('label' => 'save'));
- $expected = array(
- 'div' => array('class' => 'submit'),
- 'input' => array('type' => 'submit', 'value' => 'save'),
- '/div',
- '/form'
- );
- $this->assertTags($result, $expected);
-
- $result = $this->Form->end(array('label' => 'save', 'name' => 'Whatever'));
- $expected = array(
- 'div' => array('class' => 'submit'),
- 'input' => array('type' => 'submit', 'value' => 'save', 'name' => 'Whatever'),
- '/div',
- '/form'
- );
- $this->assertTags($result, $expected);
-
- $result = $this->Form->end(array('name' => 'Whatever'));
- $expected = array(
- 'div' => array('class' => 'submit'),
- 'input' => array('type' => 'submit', 'value' => 'Submit', 'name' => 'Whatever'),
- '/div',
- '/form'
- );
- $this->assertTags($result, $expected);
-
- $result = $this->Form->end(array('label' => 'save', 'name' => 'Whatever', 'div' => 'good'));
- $expected = array(
- 'div' => array('class' => 'good'),
- 'input' => array('type' => 'submit', 'value' => 'save', 'name' => 'Whatever'),
- '/div',
- '/form'
- );
- $this->assertTags($result, $expected);
-
- $result = $this->Form->end(array(
- 'label' => 'save', 'name' => 'Whatever', 'div' => array('class' => 'good')
- ));
- $expected = array(
- 'div' => array('class' => 'good'),
- 'input' => array('type' => 'submit', 'value' => 'save', 'name' => 'Whatever'),
- '/div',
- '/form'
- );
- $this->assertTags($result, $expected);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.