From: Andrey Kutejko Date: Mon, 25 Aug 2014 14:56:50 +0000 (+0300) Subject: cleanup forms X-Git-Tag: 0.6~158 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=c0bb3d6caf66b1b5c59e6520388183dba0869591;p=ipf.git cleanup forms --- diff --git a/ipf/form/field/modelchoice.php b/ipf/form/field/modelchoice.php deleted file mode 100644 index 91c1ee8..0000000 --- a/ipf/form/field/modelchoice.php +++ /dev/null @@ -1,28 +0,0 @@ -table = $params['table']; - if (isset($params['queryset'])) { - $choices = array('--------' => ''); - foreach ($params['queryset'] as $item) { - $choices[(string)$item] = $item->id; - } - $this->setChoices($choices); - } - } - - public function clean($value) - { - parent::clean($value); - if (in_array($value, $this->empty_values)) - return null; - return $this->table->find($value); - } -} - diff --git a/ipf/form/field/modelmultiplechoice.php b/ipf/form/field/modelmultiplechoice.php deleted file mode 100644 index f6844d7..0000000 --- a/ipf/form/field/modelmultiplechoice.php +++ /dev/null @@ -1,6 +0,0 @@ -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; }