diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 3006f9b74..231d8fa11 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -349,6 +349,14 @@ class Dispatcher extends Object { } else { $params['form'] = $_POST; } + if (isset($params['form']['_method'])) { + if (isset($_SERVER) && !empty($_SERVER)) { + $_SERVER['REQUEST_METHOD'] = $params['form']['_method']; + } else { + $_ENV['REQUEST_METHOD'] = $params['form']['_method']; + } + unset($params['form']['_method']); + } } if (isset($params['form']['data'])) { diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php index 3ac90f622..daf27b1e3 100644 --- a/cake/libs/view/helper.php +++ b/cake/libs/view/helper.php @@ -392,8 +392,11 @@ class Helper extends Overloadable { * @return mixed */ function domId($options = null, $id = 'id') { - if (is_array($options) && !isset($options[$id])) { + if (is_array($options) && !array_key_exists($id, $options)) { $options[$id] = $this->model() . Inflector::camelize($this->field()); + } elseif (is_array($options) && $options[$id] === null) { + unset($options[$id]); + return $options; } elseif (!is_array($options)) { $this->setFormTag($options); return $this->model() . Inflector::camelize($this->field()); @@ -419,7 +422,7 @@ class Helper extends Overloadable { $this->setFormTag($field); } - if (is_array($options) && isset($options[$key])) { + if (is_array($options) && array_key_exists($key, $options)) { return $options; } diff --git a/cake/libs/view/helpers/ajax.php b/cake/libs/view/helpers/ajax.php index f94976d31..6fc668a9f 100644 --- a/cake/libs/view/helpers/ajax.php +++ b/cake/libs/view/helpers/ajax.php @@ -552,7 +552,7 @@ class AjaxHelper extends AppHelper { * @return string JavaScript block to create a droppable element */ function dropRemote($id, $options = array(), $ajaxOptions = array()) { - $options['onDrop'] = "function(element, droppable) {" . $this->remoteFunction($ajaxOptions) . "}"; + $options['onDrop'] = "function(element, droppable, event) {" . $this->remoteFunction($ajaxOptions) . "}"; $options = $this->_optionsToString($options, array('accept', 'overlap', 'hoverclass')); $options = $this->_buildOptions($options, $this->dropOptions); return $this->Javascript->codeBlock("Droppables.add('{$id}', {$options});"); diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 01f47831c..42d1ef052 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -184,7 +184,7 @@ class FormHelper extends AppHelper { case 'post': case 'put': case 'delete': - //$append .= $this->hidden('_method', array('name' => '_method', 'value' => up($options['type']), 'id' => $options['id'] . 'Method')); + $append .= $this->hidden('_method', array('name' => '_method', 'value' => up($options['type']), 'id' => null)); default: $htmlAttributes['method'] = 'post'; break; @@ -709,12 +709,7 @@ class FormHelper extends AppHelper { $output = null; if (isset($object) && isset($options['value']) && ($options['value'] == 0 || $options['value'] == 1)) { $db =& ConnectionManager::getDataSource($object->useDbConfig); - if (is_object($db)) { - $value = $db->boolean($options['value'], false); - } else { - pr(get_class($object)); - pr($object->useDbConfig); - } + $value = $db->boolean($options['value'], false); $options['value'] = 1; } $output = $this->hidden($fieldName, array('value' => '0', 'id' => $options['id'] . '_'), true); @@ -856,11 +851,10 @@ class FormHelper extends AppHelper { if (!empty($options['value']) || $options['value'] === '0') { $value = $options['value']; } - $this->__secure($key, $value); - /*if (in_array($fieldName, array('_method', '_fields'))) { - $model = null; - }*/ + if (!in_array($fieldName, array('_method'))) { + $this->__secure($key, $value); + } return $this->output(sprintf($this->Html->tags['hidden'], $options['name'], $this->_parseAttributes($options, array('name', 'class'), '', ' '))); } /** diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index d13f0687d..6b79b9baa 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -44,6 +44,7 @@ class ContactTestController extends Controller { } class Contact extends CakeTestModel { + var $primaryKey = 'id'; var $useTable = false; var $name = 'Contact'; @@ -60,6 +61,7 @@ class Contact extends CakeTestModel { } class UserForm extends CakeTestModel { + var $useTable = false; var $primaryKey = 'id'; var $name = 'UserForm'; @@ -97,6 +99,7 @@ class OpenidUrl extends CakeTestModel { } class ValidateUser extends CakeTestModel { + var $primaryKey = 'id'; var $useTable = false; var $name = 'ValidateUser'; @@ -119,6 +122,7 @@ class ValidateUser extends CakeTestModel { } class ValidateProfile extends CakeTestModel { + var $primaryKey = 'id'; var $useTable = false; var $name = 'ValidateProfile'; @@ -144,6 +148,7 @@ class ValidateProfile extends CakeTestModel { } class ValidateItem extends CakeTestModel { + var $primaryKey = 'id'; var $useTable = false; var $name = 'ValidateItem'; @@ -303,7 +308,16 @@ class FormHelperTest extends CakeTestCase { $this->assertFalse($result); $result = $this->Form->create('UserForm', array('type' => 'post', 'action' => 'login')); - $this->assertPattern('/^