fixing habtm

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5967 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2007-11-08 01:44:47 +00:00
parent 58ead8aa5c
commit 42767170d1
2 changed files with 12 additions and 13 deletions

View file

@ -338,6 +338,9 @@ class Helper extends Overloadable {
$hasField = 0;
$sameScope = true;
}
if (in_array($model, array_keys($tmpModelObject->hasAndBelongsToMany))) {
$hasField = 1;
}
}
if ($parts[0] == '_Token' && isset($parts[1])) {
@ -366,6 +369,7 @@ class Helper extends Overloadable {
$view->modelId = null;
if ($view->modelScope) {
$view->association = $parts[0];
$view->field = $parts[0];
} else {
$view->model = $parts[0];
}
@ -488,6 +492,7 @@ class Helper extends Overloadable {
$this->setEntity($options);
return $this->domId();
}
$dom = $this->model() . Inflector::camelize($view->field) . Inflector::camelize($view->fieldSuffix);
if (is_array($options) && !array_key_exists($id, $options)) {

View file

@ -123,19 +123,16 @@ class FormHelper extends AppHelper {
if (empty($fields)) {
trigger_error(__('(FormHelper::create) Unable to use model field data. If you are using a model without a database table, try implementing schema()', true), E_USER_WARNING);
}
$data = array(
if (!empty($object->hasAndBelongsToMany)) {
foreach ($object->hasAndBelongsToMany as $alias => $assocData) {
$fields[$alias] = array('type' => 'multiple');
}
}
$this->fieldset = array(
'fields' => $fields,
'key' => $object->primaryKey,
'validates' => (ife(empty($object->validate), array(), array_keys($object->validate)))
);
$habtm = array();
if (!empty($object->hasAndBelongsToMany)) {
foreach ($object->hasAndBelongsToMany as $alias => $assocData) {
$data['fields'][$alias] = array('type' => 'multiple');
}
}
$this->fieldset = $data;
}
if (isset($this->data[$model]) && isset($this->data[$model][$data['key']]) && !empty($this->data[$model][$data['key']])) {
@ -509,9 +506,6 @@ class FormHelper extends AppHelper {
if (isset($map[$type])) {
$options['type'] = $map[$type];
} elseif ($type === 'multiple') {
$fieldName = $this->field().'.'.$this->field();
$this->setEntity($fieldName);
}
if ($this->field() == $primaryKey) {
$options['type'] = 'hidden';