else{
$data = $o->getData();
foreach($o->getTable()->getRelations() as $rname=>$rel){
+ $pk = $rel->getTable()->getIdentifier();
if (array_search($rname,$this->fields())){
if ($rel->getType()==IPF_ORM_Relation::MANY_AGGREGATE){
$data[$rname] = array();
foreach($rel->fetchRelatedFor($o) as $ri)
- $data[$rname][] = $ri->id;
+ $data[$rname][] = $ri->$pk;
}
}
}
{
//print_r($def);
$list_objects = IPF_ORM::getTable($def['model'])->findAll();
+ $pk = IPF_ORM::getTable($def['model'])->getIdentifier();
$choices = array();
foreach($list_objects as $o){
- $choices[$o->__toString()] = $o->id;
+ $choices[$o->__toString()] = $o->$pk;
}
$def['choices'] = $choices;
if (!isset($def['widget'])) {
if (isset($this->cleaned_data[$rname])){
//print $rel->getAlias();
$this->model->unlink($rel->getAlias());
- if (is_array($this->cleaned_data[$rname]))
+ if (is_array($this->cleaned_data[$rname])){
$this->model->link($rel->getAlias(),$this->cleaned_data[$rname]);
+ }
}
}
return $this->model;
$choices = array_merge($this->choices, $choices);
foreach ($choices as $option_label=>$option_value) {
- $selected = (in_array($option_value, $value)) ? ' selected="selected"':'';
+ $selected = (@in_array($option_value, $value)) ? ' selected="selected"':'';
$output[] = sprintf('<option value="%s"%s>%s</option>',
htmlspecialchars($option_value, ENT_COMPAT, 'UTF-8'),
$selected,
$ids[$i] = (integer) $ids[$i];
}
}
+
foreach ($ids as $id) {
$record = new $modelClassName;
$record[$localFieldName] = $identifier;