mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Allow 3.x backport of url=>false
in 2.x
This commit is contained in:
parent
6fbc029b9b
commit
b1f1003ebe
3 changed files with 33 additions and 3 deletions
|
@ -8607,6 +8607,26 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test create() with no URL (no "action" attribute for <form> tag)
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testCreateNoUrl() {
|
||||||
|
$result = $this->Form->create(false, array('url' => false));
|
||||||
|
$expected = array(
|
||||||
|
'form' => array(
|
||||||
|
'id' => 'addForm',
|
||||||
|
'method' => 'post',
|
||||||
|
'accept-charset' => strtolower(Configure::read('App.encoding'))
|
||||||
|
),
|
||||||
|
'div' => array('style' => 'display:none;'),
|
||||||
|
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
|
||||||
|
'/div'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the onsubmit option for create()
|
* Test the onsubmit option for create()
|
||||||
*
|
*
|
||||||
|
|
|
@ -393,7 +393,7 @@ class FormHelper extends AppHelper {
|
||||||
|
|
||||||
if ($options['action'] === null && $options['url'] === null) {
|
if ($options['action'] === null && $options['url'] === null) {
|
||||||
$options['action'] = $this->request->here(false);
|
$options['action'] = $this->request->here(false);
|
||||||
} elseif (empty($options['url']) || is_array($options['url'])) {
|
} elseif (is_array($options['url'])) {
|
||||||
if (empty($options['url']['controller'])) {
|
if (empty($options['url']['controller'])) {
|
||||||
if (!empty($model)) {
|
if (!empty($model)) {
|
||||||
$options['url']['controller'] = Inflector::underscore(Inflector::pluralize($model));
|
$options['url']['controller'] = Inflector::underscore(Inflector::pluralize($model));
|
||||||
|
@ -421,7 +421,6 @@ class FormHelper extends AppHelper {
|
||||||
} elseif (is_string($options['url'])) {
|
} elseif (is_string($options['url'])) {
|
||||||
$options['action'] = $options['url'];
|
$options['action'] = $options['url'];
|
||||||
}
|
}
|
||||||
unset($options['url']);
|
|
||||||
|
|
||||||
switch (strtolower($options['type'])) {
|
switch (strtolower($options['type'])) {
|
||||||
case 'get':
|
case 'get':
|
||||||
|
@ -442,7 +441,13 @@ class FormHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
$this->requestType = strtolower($options['type']);
|
$this->requestType = strtolower($options['type']);
|
||||||
|
|
||||||
|
if ($options['action'] === false || $options['url'] === false) {
|
||||||
|
$action = null;
|
||||||
|
} else {
|
||||||
$action = $this->url($options['action']);
|
$action = $this->url($options['action']);
|
||||||
|
}
|
||||||
|
unset($options['url']);
|
||||||
|
|
||||||
$this->_lastAction($options['action']);
|
$this->_lastAction($options['action']);
|
||||||
unset($options['type'], $options['action']);
|
unset($options['type'], $options['action']);
|
||||||
|
|
||||||
|
@ -475,6 +480,10 @@ class FormHelper extends AppHelper {
|
||||||
$this->_introspectModel($model, 'fields');
|
$this->_introspectModel($model, 'fields');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($action === null) {
|
||||||
|
return $this->Html->useTag('formwithoutaction', $htmlAttributes) . $append;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->Html->useTag('form', $action, $htmlAttributes) . $append;
|
return $this->Html->useTag('form', $action, $htmlAttributes) . $append;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ class HtmlHelper extends AppHelper {
|
||||||
'link' => '<a href="%s"%s>%s</a>',
|
'link' => '<a href="%s"%s>%s</a>',
|
||||||
'mailto' => '<a href="mailto:%s"%s>%s</a>',
|
'mailto' => '<a href="mailto:%s"%s>%s</a>',
|
||||||
'form' => '<form action="%s"%s>',
|
'form' => '<form action="%s"%s>',
|
||||||
|
'formwithoutaction' => '<form%s>',
|
||||||
'formend' => '</form>',
|
'formend' => '</form>',
|
||||||
'input' => '<input name="%s"%s/>',
|
'input' => '<input name="%s"%s/>',
|
||||||
'textarea' => '<textarea name="%s"%s>%s</textarea>',
|
'textarea' => '<textarea name="%s"%s>%s</textarea>',
|
||||||
|
|
Loading…
Reference in a new issue