/** * @param string $layout * * @return string */ public function render($layout = 'edit') { $column = $this->_params->getParam('name'); $prefix = $this->_params->getParam('source'); $fieldId = ($prefix ? $prefix . '_' : '') . $column; $fieldName = $prefix ? $prefix . '[' . $column . ']' : $column; $defaultParams = $this->_params->getParams(); unset($defaultParams['name']); $tagParams = array_merge([$fieldName], $this->_params->getParam('tag', []), ['value' => $this->getValue(), 'id' => $fieldId] + $defaultParams); $this->_params->setParam('id', $fieldId); // все параметры уже добавлены, в общем списке они не нужны unset($tagParams['tag']); $tagParams['class'] = isset($tagParams['class']) ? $tagParams['class'] . ' form-control' : 'form-control'; $layout = $this->_params->getParam('options.layout', $layout); $this->beforeRender($tagParams); $this->_view->setLayout($layout); $this->_view->setVars(['field' => $this, 'model' => $this->_model, 'params' => $this->_params, 'tag' => $tagParams]); return $this->_view->getRender($this->getLayoutDir($layout), $layout); }
<?php /** * Created by Rem. * Author: Dmitry Kushneriv * Email: remkwadriga@yandex.ua * Date: 07-08-2015 * Time: 16:10 PM * * @var \Phalcon\Config $config */ use Phalcon\Mvc\View; use Phalcon\Mvc\View\Engine\Volt as VoltEngine; $view = new View(); $view->setViewsDir($config->application->viewsDir); $view->setVars($config->view->vars->toArray()); $view->registerEngines(['.volt' => function ($view, $di) use($config) { $volt = new VoltEngine($view, $di); $volt->setOptions($config->volt->options->toArray()); $functions = $config->volt->functions->toArray(); foreach ($functions as $name => $function) { $volt->getCompiler()->addFunction($name, function ($params) use($function) { if (is_array($function)) { $funcArray = $function; $function = $funcArray['function']; if (isset($funcArray['params']) && !empty($funcArray['params'])) { if (!is_array($params)) { $params = (array) $params; } $params = array_merge($params, $funcArray['params']); $params = serialize(array_filter($params));