From c0bb3d6caf66b1b5c59e6520388183dba0869591 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Mon, 25 Aug 2014 17:56:50 +0300 Subject: [PATCH] cleanup forms --- ipf/form/field/modelchoice.php | 28 -------------------------- ipf/form/field/modelmultiplechoice.php | 6 ------ ipf/legacy_orm/modelform.php | 16 +++++++++------ 3 files changed, 10 insertions(+), 40 deletions(-) delete mode 100644 ipf/form/field/modelchoice.php delete mode 100644 ipf/form/field/modelmultiplechoice.php 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; } -- 2.49.0