mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Making sure forms always have a generated id attribute. Updating tests.
This commit is contained in:
parent
6fd5ff34a0
commit
c6b7482308
2 changed files with 9 additions and 9 deletions
|
@ -238,11 +238,14 @@ class FormHelper extends AppHelper {
|
|||
$options);
|
||||
$this->_inputDefaults = $options['inputDefaults'];
|
||||
unset($options['inputDefaults']);
|
||||
|
||||
if (!isset($options['id'])) {
|
||||
$domId = isset($options['action']) ? $options['action'] : $this->request['action'];
|
||||
$options['id'] = $this->domId($domId . 'Form');
|
||||
}
|
||||
|
||||
if ($options['action'] === null && $options['url'] === null) {
|
||||
$options['action'] = $this->request->here(false);
|
||||
if (!isset($options['id'])) {
|
||||
$options['id'] = $this->domId($this->request['action'] . 'Form');
|
||||
}
|
||||
} elseif (empty($options['url']) || is_array($options['url'])) {
|
||||
if (empty($options['url']['controller'])) {
|
||||
if (!empty($model) && $model != $this->defaultModel) {
|
||||
|
@ -260,9 +263,6 @@ class FormHelper extends AppHelper {
|
|||
'controller' => $this->_View->viewPath,
|
||||
'action' => $options['action'],
|
||||
);
|
||||
if (!empty($options['action']) && !isset($options['id'])) {
|
||||
$options['id'] = $this->domId($options['action'] . 'Form');
|
||||
}
|
||||
$options['action'] = array_merge($actionDefaults, (array)$options['url']);
|
||||
if (empty($options['action'][0]) && !empty($id)) {
|
||||
$options['action'][0] = $id;
|
||||
|
|
|
@ -723,7 +723,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
$encoding = strtolower(Configure::read('App.encoding'));
|
||||
$result = $this->Form->create('Contact', array('url' => '/contacts/add'));
|
||||
$expected = array(
|
||||
'form' => array('method' => 'post', 'action' => '/contacts/add', 'accept-charset' => $encoding),
|
||||
'form' => array('method' => 'post', 'action' => '/contacts/add', 'accept-charset' => $encoding, 'id' => 'ContactAddForm'),
|
||||
'div' => array('style' => 'display:none;'),
|
||||
array('input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST')),
|
||||
array('input' => array(
|
||||
|
@ -1104,7 +1104,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
$result = $this->Form->create('Contact', array('url' => '/contacts/add'));
|
||||
$encoding = strtolower(Configure::read('App.encoding'));
|
||||
$expected = array(
|
||||
'form' => array('method' => 'post', 'action' => '/contacts/add', 'accept-charset' => $encoding),
|
||||
'form' => array('method' => 'post', 'action' => '/contacts/add', 'accept-charset' => $encoding, 'id' => 'ContactAddForm'),
|
||||
'div' => array('style' => 'display:none;'),
|
||||
array('input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST')),
|
||||
array('input' => array(
|
||||
|
@ -5659,7 +5659,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Form->create('User', array('url' => '/users/login'));
|
||||
$expected = array(
|
||||
'form' => array('method' => 'post', 'action' => '/users/login','accept-charset' => $encoding),
|
||||
'form' => array('method' => 'post', 'action' => '/users/login', 'accept-charset' => $encoding, 'id' => 'UserAddForm'),
|
||||
'div' => array('style' => 'display:none;'),
|
||||
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
|
||||
'/div'
|
||||
|
|
Loading…
Reference in a new issue