From 6573c07d09994aa2b1cddd74de14e33c0e000c8c Mon Sep 17 00:00:00 2001 From: Anatoly Date: Thu, 30 Nov 2017 10:58:50 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=81=D0=BF=D0=B8=D1=81=D0=BE=D0=BA=20=D0=BE?= =?UTF-8?q?=D0=BF=D1=86=D0=B8=D0=B9=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7=20?= =?UTF-8?q?=D0=BC=D1=8D=D0=BF=D0=BF=D0=B5=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/Component.php | 2 +- src/Form/Form.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Controller/Component.php b/src/Controller/Component.php index 99ca77c..d6886f8 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -175,7 +175,7 @@ class Controller_Component public function setParameters(/*.View_Composite.*/$view) { $form = new Form_Form(); - $options = new OptionFactory($this->db); + $options = new OptionFactory($this->db, $this->registry); $settings = $this->getInfo(); $form->addFieldList($settings['parameter'], $options); diff --git a/src/Form/Form.php b/src/Form/Form.php index f0e6922..c4caafe 100644 --- a/src/Form/Form.php +++ b/src/Form/Form.php @@ -190,9 +190,10 @@ class TDateTime extends TInput { class OptionFactory { public $db; - - function __construct($db) { + public $registry; + function __construct($db, $registry = null) { $this->db = $db; + $this->registry = $registry; } function create(TSelect $field, $input) { @@ -225,6 +226,10 @@ class OptionFactory { $field->options = $this->optionsDB($key, $value, $query_result); } elseif (isset($input['options.pair'])) { $field->options = $this->optionsPair($input['options.pair']); + } elseif (isset($input['options.model'])) { + $factory = new Model_Factory($this->db, $this->registry); + $model = $factory->getModel($input['options.model']); + $field->options = $model->getAllAsOptions(); } else { $field->options = $input['options']; }