Skip to content
Permalink
Browse files

Deprecate action in Form::create()

  • Loading branch information...
dereuromark committed Jan 4, 2016
1 parent 0aa8847 commit a2ce6c8c1fd1d0fdbd80b514cbc9b95f0b147b4d
Showing with 13 additions and 9 deletions.
  1. +5 −5 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
  2. +8 −4 lib/Cake/View/Helper/FormHelper.php
@@ -1780,7 +1780,7 @@ public function testFormValidationAssociated() {
$this->assertFalse(empty($result));
$this->assertFalse($this->UserForm->OpenidUrl->validates());
$result = $this->Form->create('UserForm', array('type' => 'post', 'action' => 'login'));
$result = $this->Form->create('UserForm', array('type' => 'post', 'url' => array('action' => 'login')));
$encoding = strtolower(Configure::read('App.encoding'));
$expected = array(
'form' => array(
@@ -1822,7 +1822,7 @@ public function testFormValidationAssociatedFirstLevel() {
$this->assertFalse($this->ValidateUser->validates());
$this->assertFalse($this->ValidateUser->ValidateProfile->validates());
$result = $this->Form->create('ValidateUser', array('type' => 'post', 'action' => 'add'));
$result = $this->Form->create('ValidateUser', array('type' => 'post', 'url' => array('action' => 'add')));
$encoding = strtolower(Configure::read('App.encoding'));
$expected = array(
'form' => array('method' => 'post', 'action' => '/validate_users/add', 'id', 'accept-charset' => $encoding),
@@ -1875,7 +1875,7 @@ public function testFormValidationAssociatedSecondLevel() {
$this->assertFalse($this->ValidateUser->ValidateProfile->validates());
$this->assertFalse($this->ValidateUser->ValidateProfile->ValidateItem->validates());
$result = $this->Form->create('ValidateUser', array('type' => 'post', 'action' => 'add'));
$result = $this->Form->create('ValidateUser', array('type' => 'post', 'url' => array('action' => 'add')));
$encoding = strtolower(Configure::read('App.encoding'));
$expected = array(
'form' => array('method' => 'post', 'action' => '/validate_users/add', 'id', 'accept-charset' => $encoding),
@@ -8688,7 +8688,7 @@ public function testCreateCustomRoute() {
Router::connect('/login', array('controller' => 'users', 'action' => 'login'));
$encoding = strtolower(Configure::read('App.encoding'));
$result = $this->Form->create('User', array('action' => 'login'));
$result = $this->Form->create('User', array('url' => array('action' => 'login')));
$expected = array(
'form' => array(
'id' => 'UserLoginForm', 'method' => 'post', 'action' => '/login',
@@ -8760,7 +8760,7 @@ public function testCreateWithInputDefaults() {
*/
public function testCreateWithAcceptCharset() {
$result = $this->Form->create('UserForm', array(
'type' => 'post', 'action' => 'login', 'encoding' => 'iso-8859-1'
'type' => 'post', 'url' => array('action' => 'login'), 'encoding' => 'iso-8859-1'
)
);
$expected = array(
@@ -312,19 +312,19 @@ public function tagIsInvalid() {
* ### Options:
*
* - `type` Form method defaults to POST
* - `action` The controller action the form submits to, (optional).
* - `action` The controller action the form submits to, (optional). Deprecated since 2.8, use `url`.
* - `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.
* - `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.
* - `onsubmit` Used in conjunction with 'default' to create AJAX forms.
* - `inputDefaults` set the default $options for FormHelper::input(). Any options that would
* be set when using FormHelper::input() can be set here. Options set with `inputDefaults`
* can be overridden when calling input()
* - `encoding` Set the accept-charset encoding for the form. Defaults to `Configure::read('App.encoding')`
*
* @param mixed $model The model name for which the form is being defined. Should
* @param mixed|null $model The model name for which the form is being defined. Should
* include the plugin name for plugin models. e.g. `ContactManager.Contact`.
* If an array is passed and $options argument is empty, the array will be used as options.
* If `false` no model is used.
@@ -379,6 +379,10 @@ public function create($model = null, $options = array()) {
$this->inputDefaults($options['inputDefaults']);
unset($options['inputDefaults']);
if (isset($options['action'])) {
trigger_error('Using key `action` is deprecated, use `url` directly instead.', E_USER_DEPRECATED);
}
if (!isset($options['id'])) {
$domId = isset($options['action']) ? $options['action'] : $this->request['action'];
$options['id'] = $this->domId($domId . 'Form');

0 comments on commit a2ce6c8

Please sign in to comment.
You can’t perform that action at this time.