Возможность получить список опций через мэппер

This commit is contained in:
Anatoly 2017-11-30 10:58:50 +03:00
parent e6686e3bd3
commit 6573c07d09
2 changed files with 8 additions and 3 deletions

View file

@ -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);

View file

@ -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'];
}