From 441c2704e068ab39a45e1ab838b68482c739d9db Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Mon, 25 Aug 2014 17:56:50 +0300 Subject: [PATCH] cleanup forms --- ipf/legacy_orm/modelform.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ipf/legacy_orm/modelform.php b/ipf/legacy_orm/modelform.php index 89ffed1..fe9cb93 100644 --- a/ipf/legacy_orm/modelform.php +++ b/ipf/legacy_orm/modelform.php @@ -174,19 +174,23 @@ class IPF_Form_Model extends IPF_Form ); if ($rt === IPF_ORM_Relation::ONE_AGGREGATE) { - $params['queryset'] = $table->findAll(); - return array($name.'_id', new IPF_Form_Field_ModelChoice($params)); - } elseif ($rt === IPF_ORM_Relation::MANY_AGGREGATE) { - + $choices = array('--------' => ''); $pk = $table->getIdentifier(); + foreach ($table->findAll() as $o) { + $choices[$o->__toString()] = $o->$pk; + } + + $params['choices'] = $choices; + return array($name.'_id', new IPF_Form_Field_Choice($params)); + } elseif ($rt === IPF_ORM_Relation::MANY_AGGREGATE) { $choices = array(); + $pk = $table->getIdentifier(); foreach ($table->findAll() as $o) { $choices[$o->__toString()] = $o->$pk; } $params['choices'] = $choices; - $params['widget'] = 'IPF_Form_Widget_SelectMultipleInput'; - return array($name, new IPF_Form_Field_ModelMultipleChoice($params)); + return array($name, new IPF_Form_Field_MultipleChoice($params)); } else { return null; } -- 2.49.0