diff --git a/src/View/Helper/FormHelper.php b/src/View/Helper/FormHelper.php index b94a7b59425..a549bc6adae 100755 --- a/src/View/Helper/FormHelper.php +++ b/src/View/Helper/FormHelper.php @@ -253,10 +253,6 @@ protected function _isRequiredField($validationRules) { * don't need to change the controller from the current request's controller. * - `url` The URL the form submits to. Can be a string or a URL array. If you use 'url' * you should leave 'action' undefined. - * - `default` Allows for the creation of Ajax forms. Set this to false to prevent the default event handler. - * Will create an onsubmit attribute if it doesn't not exist. If it does, default action suppression - * will be appended. - * - `onsubmit` Used in conjunction with 'default' to create ajax forms. * - `encoding` Set the accept-charset encoding for the form. Defaults to `Configure::read('App.encoding')` * - `context` Additional options for the context class. For example the EntityContext accepts a 'table' * option that allows you to set the specific Table class the form should be based on. @@ -284,7 +280,6 @@ public function create($model = null, $options = []) { 'type' => $isCreate ? 'post' : 'put', 'action' => null, 'url' => null, - 'default' => true, 'encoding' => strtolower(Configure::read('App.encoding')), ]; @@ -313,17 +308,10 @@ public function create($model = null, $options = []) { } $this->requestType = strtolower($options['type']); - if (!$options['default']) { - if (!isset($options['onsubmit'])) { - $options['onsubmit'] = ''; - } - $htmlAttributes['onsubmit'] = $options['onsubmit'] . 'event.returnValue = false; return false;'; - } - if (!empty($options['encoding'])) { $htmlAttributes['accept-charset'] = $options['encoding']; } - unset($options['type'], $options['encoding'], $options['default']); + unset($options['type'], $options['encoding']); $htmlAttributes = array_merge($options, $htmlAttributes); diff --git a/tests/TestCase/View/Helper/FormHelperTest.php b/tests/TestCase/View/Helper/FormHelperTest.php index 85f153f0ffa..7a74ac2ed22 100755 --- a/tests/TestCase/View/Helper/FormHelperTest.php +++ b/tests/TestCase/View/Helper/FormHelperTest.php @@ -384,48 +384,6 @@ public function testCreateUpdateForm() { $this->assertTags($result, $expected); } -/** - * Test the onsubmit option for create() - * - * @return void - */ - public function testCreateOnSubmit() { - $this->Form->request->data = []; - $this->Form->request['controller'] = 'articles'; - $result = $this->Form->create($this->article, ['url' => ['action' => 'index', 'param'], 'default' => false]); - $expected = array( - 'form' => array( - 'method' => 'post', 'onsubmit' => 'event.returnValue = false; return false;', 'action' => '/articles/index/param', - 'accept-charset' => 'utf-8' - ), - 'div' => array('style' => 'display:none;'), - 'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'), - '/div' - ); - $this->assertTags($result, $expected); - - $this->Form->request->data = []; - $this->Form->request['controller'] = 'articles'; - $result = $this->Form->create($this->article, array( - 'url' => array('action' => 'index', 'param'), - 'default' => false, - 'onsubmit' => 'someFunction();' - )); - - $expected = array( - 'form' => array( - 'method' => 'post', - 'onsubmit' => 'someFunction();event.returnValue = false; return false;', - 'action' => '/articles/index/param', - 'accept-charset' => 'utf-8' - ), - 'div' => array('style' => 'display:none;'), - 'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'), - '/div' - ); - $this->assertTags($result, $expected); - } - /** * test create() with automatic url generation *