mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merging fixes to trunk
Revision: [1829] Fixing AjaxHelper::form() Revision: [1828] Added check to return false is passing an empty string to requestAction(), method would seg fault if param was empty. Fixing another problem found when passing fields to the model methods. git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1830 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
58e7bbc224
commit
3984795205
4 changed files with 56 additions and 15 deletions
|
@ -6,4 +6,4 @@
|
|||
// +---------------------------------------------------------------------------------------------------+ //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
0.10.6.1827 RC 1
|
||||
0.10.6.1830 RC 2
|
|
@ -366,6 +366,7 @@ class DboSource extends DataSource
|
|||
$null = null;
|
||||
$array = array();
|
||||
$linkedModels = array();
|
||||
$this->__bypass = false;
|
||||
|
||||
if(!empty($queryData['fields']))
|
||||
{
|
||||
|
|
|
@ -96,21 +96,28 @@ class Object
|
|||
*/
|
||||
function requestAction ($url, $extra = array())
|
||||
{
|
||||
$dispatcher =& new Dispatcher();
|
||||
if(in_array('return', $extra))
|
||||
if(!empty($url))
|
||||
{
|
||||
$extra['return'] = 0;
|
||||
$extra['bare'] = 1;
|
||||
$dispatcher =& new Dispatcher();
|
||||
if(in_array('return', $extra))
|
||||
{
|
||||
$extra['return'] = 0;
|
||||
$extra['bare'] = 1;
|
||||
ob_start();
|
||||
$out = $dispatcher->dispatch($url, $extra);
|
||||
$out = ob_get_clean();
|
||||
return $out;
|
||||
}
|
||||
else
|
||||
{
|
||||
$extra['return'] = 1;
|
||||
$extra['bare'] = 1;
|
||||
return $dispatcher->dispatch($url, $extra);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$extra['return'] = 1;
|
||||
$extra['bare'] = 1;
|
||||
return $dispatcher->dispatch($url, $extra);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -257,17 +257,50 @@ class AjaxHelper extends Helper
|
|||
* will work just like a regular submission as viewed by the receiving side (all elements available in params).
|
||||
* The options for specifying the target with :url and defining callbacks is the same as link_to_remote.
|
||||
*
|
||||
* @param string $id Form id
|
||||
* @param array $html_options HTML tag options
|
||||
* @param array $options Callback options
|
||||
* @return string JavaScript code
|
||||
* @param array $params Form id
|
||||
* @param array $type How form data is posted: 'get' or 'post'
|
||||
* @param array $options Callback/HTML options
|
||||
* @return string JavaScript/HTML code
|
||||
*/
|
||||
function form($id, $options = array())
|
||||
function form($params = null, $type = 'post', $options = array())
|
||||
{
|
||||
if (is_array($params))
|
||||
{
|
||||
extract($params, EXTR_OVERWRITE);
|
||||
if (!isset($action))
|
||||
{
|
||||
$action = null;
|
||||
}
|
||||
if (!isset($type))
|
||||
{
|
||||
$type = 'post';
|
||||
}
|
||||
if (!isset($options))
|
||||
{
|
||||
$options = array();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$action = $params;
|
||||
}
|
||||
|
||||
$htmlOptions = $this->__getHtmlOptions($options);
|
||||
$htmlOptions['id'] = $id;
|
||||
$htmlOptions['action'] = $action;
|
||||
|
||||
if(!isset($htmlOptions['id']))
|
||||
{
|
||||
$htmlOptions['id'] = 'form'.intval(rand());
|
||||
}
|
||||
$htmlOptions['onsubmit'] = "return false;";
|
||||
return $this->Html->formTag(null, "post", $htmlOptions) . $this->Javascript->event("$('$id')", "submit", "function(){" . $this->remoteFunction($options) . ";}");
|
||||
|
||||
if(!isset($options['with']))
|
||||
{
|
||||
$options['with'] = 'Form.serialize(this)';
|
||||
}
|
||||
$options['url'] = $action;
|
||||
|
||||
return $this->Html->formTag($htmlOptions['action'], $type, $htmlOptions) . $this->Javascript->event("$('".$htmlOptions['id']."')", "submit", "function(){" . $this->remoteFunction($options) . ";}");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue