Starting to update FormHelper's internals to work with changes in

Helper.
This commit is contained in:
Mark Story 2011-06-25 01:40:50 -04:00
parent 3a847ae28f
commit b7e554fcd7

View file

@ -229,12 +229,11 @@ class FormHelper extends AppHelper {
if ($model !== false) {
$object = $this->_introspectModel($model);
$this->setEntity($model . '.', true);
}
$this->setEntity($model, true);
$modelEntity = $this->model();
if ($model !== false && isset($this->fieldset[$modelEntity]['key'])) {
$data = $this->fieldset[$modelEntity];
if ($model !== false && isset($this->fieldset[$model]['key'])) {
$data = $this->fieldset[$model];
$recordExists = (
isset($this->request->data[$model]) &&
!empty($this->request->data[$model][$data['key']]) &&
@ -306,7 +305,8 @@ class FormHelper extends AppHelper {
case 'put':
case 'delete':
$append .= $this->hidden('_method', array(
'name' => '_method', 'value' => strtoupper($options['type']), 'id' => null
'name' => '_method', 'value' => strtoupper($options['type']), 'id' => null,
'secure' => self::SECURE_SKIP
));
default:
$htmlAttributes['method'] = 'post';
@ -337,8 +337,9 @@ class FormHelper extends AppHelper {
$this->fields = array();
if (!empty($this->request->params['_Token'])) {
$append .= $this->hidden('_Token.key', array(
'value' => $this->request->params['_Token']['key'], 'id' => 'Token' . mt_rand())
);
'value' => $this->request->params['_Token']['key'], 'id' => 'Token' . mt_rand(),
'secure' => self::SECURE_SKIP
));
if (!empty($this->request['_Token']['unlockedFields'])) {
foreach ((array)$this->request['_Token']['unlockedFields'] as $unlocked) {
@ -351,7 +352,6 @@ class FormHelper extends AppHelper {
$append = $this->Html->useTag('block', ' style="display:none;"', $append);
}
$this->setEntity($model . '.', true);
return $this->Html->useTag('form', $action, $htmlAttributes) . $append;
}
@ -1297,9 +1297,8 @@ class FormHelper extends AppHelper {
$options = $this->_initInputField($fieldName, array_merge(
$options, array('secure' => self::SECURE_SKIP)
));
$model = $this->model();
if ($fieldName !== '_method' && $model !== '_Token' && $secure) {
if ($secure && $secure !== self::SECURE_SKIP) {
$this->__secure(true, null, '' . $options['value']);
}
@ -2349,18 +2348,20 @@ class FormHelper extends AppHelper {
$secure = (isset($this->request['_Token']) && !empty($this->request['_Token']));
}
$result = parent::_initInputField($field, $options);
if ($secure === self::SECURE_SKIP) {
return $result;
}
$fieldName = null;
if ($secure && !empty($options['name'])) {
if (!empty($options['name'])) {
preg_match_all('/\[(.*?)\]/', $options['name'], $matches);
if (isset($matches[1])) {
$fieldName = $matches[1];
}
}
$result = parent::_initInputField($field, $options);
if ($secure !== self::SECURE_SKIP) {
$this->__secure($secure, $fieldName);
}
return $result;
}
}