mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-07 03:52:41 +00:00
making it possible to use FormHelper without a model
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4238 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
f8f2df5053
commit
6f8489b52e
1 changed files with 16 additions and 13 deletions
|
@ -78,26 +78,28 @@ class FormHelper extends AppHelper {
|
||||||
$options = $model;
|
$options = $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($model) || is_array($model)) {
|
if (!is_null($model) && (empty($model) || is_array($model))) {
|
||||||
$model = $this->params['models'][0];
|
$model = $this->params['models'][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ClassRegistry::isKeySet($model)) {
|
if (ClassRegistry::isKeySet($model)) {
|
||||||
$object =& ClassRegistry::getObject($model);
|
$object =& ClassRegistry::getObject($model);
|
||||||
} else {
|
} else {
|
||||||
trigger_error(sprintf(__('Model %s does not exist', true), $model), E_USER_WARNING);
|
//trigger_error(sprintf(__('Model %s does not exist', true), $model), E_USER_WARNING);
|
||||||
return;
|
//return;
|
||||||
}
|
}
|
||||||
$this->setFormTag($model . '/');
|
$this->setFormTag($model . '/');
|
||||||
|
|
||||||
$append = '';
|
$append = '';
|
||||||
$created = false;
|
$created = false;
|
||||||
|
if(!is_null($model)) {
|
||||||
$fields = $object->loadInfo();
|
$fields = $object->loadInfo();
|
||||||
$data = array(
|
$data = array(
|
||||||
'fields' => array_combine($fields->extract('{n}.name'), $fields->extract('{n}.type')),
|
'fields' => array_combine($fields->extract('{n}.name'), $fields->extract('{n}.type')),
|
||||||
'key' => $object->primaryKey,
|
'key' => $object->primaryKey,
|
||||||
'validates' => array_keys($object->validate)
|
'validates' => array_keys($object->validate)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($this->data[$model]) && isset($this->data[$model][$data['key']]) && !empty($this->data[$model][$data['key']])) {
|
if (isset($this->data[$model]) && isset($this->data[$model][$data['key']]) && !empty($this->data[$model][$data['key']])) {
|
||||||
$created = true;
|
$created = true;
|
||||||
|
@ -353,7 +355,9 @@ class FormHelper extends AppHelper {
|
||||||
$selected = $options['selected'];
|
$selected = $options['selected'];
|
||||||
unset($options['selected']);
|
unset($options['selected']);
|
||||||
}
|
}
|
||||||
|
if(isset($options['rows']) || isset($options['cols'])) {
|
||||||
|
$options['type'] = 'textarea';
|
||||||
|
}
|
||||||
$empty = (isset($options['empty']) ? $options['empty'] : '');
|
$empty = (isset($options['empty']) ? $options['empty'] : '');
|
||||||
unset($options['empty']);
|
unset($options['empty']);
|
||||||
|
|
||||||
|
@ -600,8 +604,7 @@ class FormHelper extends AppHelper {
|
||||||
if (isset($attributes['type'])) {
|
if (isset($attributes['type'])) {
|
||||||
unset($attributes['type']);
|
unset($attributes['type']);
|
||||||
}
|
}
|
||||||
if (isset($attributes['showParents']) && $attributes['showParents']) {
|
if (in_array('showParents', $attributes)) {
|
||||||
unset($attributes['showParents']);
|
|
||||||
$showParents = true;
|
$showParents = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue