mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing issues in PrototypeEngineHelper where parameters would end up wrapped in a function() {} when marked as a dataExpression. This prevented the sending of form data.
Tests added. Fixes #142
This commit is contained in:
parent
93ced3be46
commit
32683d3d64
2 changed files with 13 additions and 3 deletions
|
@ -234,13 +234,12 @@ class PrototypeEngineHelper extends JsBaseEngineHelper {
|
|||
$type = '.Updater';
|
||||
unset($options['update'], $options['type']);
|
||||
}
|
||||
$safe = array();
|
||||
$safe = array_keys($this->_callbackArguments['request']);
|
||||
$options = $this->_prepareCallbacks('request', $options, $safe);
|
||||
if (isset($options['dataExpression'])) {
|
||||
$safe[] = 'parameters';
|
||||
unset($options['dataExpression']);
|
||||
}
|
||||
$safe = array_merge($safe, array_keys($this->_callbackArguments['request']));
|
||||
$options = $this->_prepareCallbacks('request', $options, $safe);
|
||||
$options = $this->_parseOptions($options, $safe);
|
||||
if (!empty($options)) {
|
||||
$options = ', {' . $options . '}';
|
||||
|
|
|
@ -247,6 +247,17 @@ class PrototypeEngineHelperTestCase extends CakeTestCase {
|
|||
));
|
||||
$expected = 'var jsRequest = new Ajax.Request("/people/edit/1", {asynchronous:false, method:"post", onComplete:function (transport) {doComplete();}, onCreate:function (transport) {doBefore();}, onFailure:function (response, jsonHeader) {handleError();}, onSuccess:function (response, jsonHeader) {doSuccess();}});';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Proto->get('#submit');
|
||||
$result = $this->Proto->request('/users/login', array(
|
||||
'before' => 'login.create(event)',
|
||||
'complete' => 'login.complete(event)',
|
||||
'update' => 'auth',
|
||||
'data' => $this->Proto->serializeForm(array('isForm' => false, 'inline' => true)),
|
||||
'dataExpression' => true
|
||||
));
|
||||
$this->assertTrue(strpos($result, '$($("submit").form).serialize()') > 0);
|
||||
$this->assertFalse(strpos($result, 'parameters:function () {$($("submit").form).serialize()}') > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue