From: Andrey Kutejko Date: Mon, 25 Aug 2014 14:56:50 +0000 (+0300) Subject: cleanup forms X-Git-Tag: 0.6~18 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=441c2704e068ab39a45e1ab838b68482c739d9db;p=ipf-legacy-orm.git cleanup forms --- 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; }