/** * Load default decorators * * Disables "for" attribute of label if label decorator enabled. * * @return void */ public function loadDefaultDecorators() { parent::loadDefaultDecorators(); if (false !== ($decorator = $this->getDecorator('Label'))) { $decorator->setOption('disableFor', true); } }
protected function _translateOption($option, $value) { if ($this->_translateOptions !== false) { return parent::_translateOption($option, $value); } else { return false; } }
/** * Load default decorators * * Disables "for" attribute of label if label decorator enabled. * * @return void */ public function loadDefaultDecorators() { if ($this->loadDefaultDecoratorsIsDisabled()) { return; } parent::loadDefaultDecorators(); $this->addDecorator('Label', array('tag' => 'dt', 'disableFor' => true)); }
/** * constructor * @param $spec * @param $options */ public function __construct($spec, $options = null) { $objLoader = new PluginLoader(); $objLoader->setPluginLoader($this->getPluginLoader(PluginLoader::TYPE_FORM_DECORATOR)); $objLoader->setPluginType(PluginLoader::TYPE_FORM_DECORATOR); $this->setPluginLoader($objLoader, PluginLoader::TYPE_FORM_DECORATOR); parent::__construct($spec, $options); }
/** * Определяем массив модулей и дергаем родительский конструктор * * @param mixed $spec * @param array $options */ public function __construct($spec, $options = null) { require_once 'Phorm/Resource.php'; $Resource = new Phorm_Resource(); $pairs = isset($options['multioptions']) && is_array($options['multioptions']) ? $options['multioptions'] : array(); $options['multioptions'] = $pairs + $Resource->getModulesListAsPairs(); parent::__construct($spec, $options); }
/** * Определяем массив опций и дергаем родительский конструктор * * @param mixed $spec * @param array $options */ public function __construct($spec, $options = null) { require_once "Phorm/Structures.php"; $Structures = new Phorm_Structures(); $options['multioptions'] = $Structures->getPropertiesListAsPairs(); //$this->setSeparator('</li><li>'); // Почему-то нельзя передать в помощнике вида в formRadio... parent::__construct($spec, $options); }
/** * Определяем массив опций и дергаем родительский конструктор * * @param mixed $spec * @param array $options */ public function __construct($spec, $options = null) { require_once "Phorm/Widget.php"; $translate = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('Translate'); $Widget = new Phorm_Widget(); $Widgets = array(null => $translate->_('---Выберите---')) + $Widget->getWidgetsSetsList(); $options['multioptions'] = $Widgets; parent::__construct($spec, $options); }
public function isValid($value, $context = null) { if ($this->registerInArrayValidator()) { if (!$this->getValidator('InArray')) { $multi_options = $this->getMultiOptions(); $option_ids = $this->_getOptionIds($multi_options); $this->addValidator('InArray', true, array($option_ids)); } } return parent::isValid($value, $context); }
/** * @brief Redéfinition de la méthode isValid pour permettre l'affichage des erreurs propres à chaque champ * @see Zend_Form_Element_Multi::isValid() * @author francoisespinet * @version 13 avr. 2012 - 11:51:14 */ public function isValid($value, $context = null) { $aResult = parent::isValid($value, $context); /* * Dans le cas ou le validateur MultiMail est présent (et que le formulaire à des erreurs), * on transfére ces erreur dans les atributs de l'objet multimail pour y acceder dans le décorateur */ if (($oValid = $this->getValidator('MultiMail')) && $this->hasErrors()) { $this->_InvalidChamps = $oValid->getAdressesInvalides(); } return $aResult; }
/** * Load default decorators * * Disables "for" attribute of label if label decorator enabled. * * @return Zend_Form_Element_Radio */ public function loadDefaultDecorators() { if ($this->loadDefaultDecoratorsIsDisabled()) { return $this; } parent::loadDefaultDecorators(); // Disable 'for' attribute if (isset($this->_decorators['Label']) && !isset($this->_decorators['Label']['options']['disableFor'])) { $this->_decorators['Label']['options']['disableFor'] = true; } return $this; }
/** * Load default decorators * * @return Zend_Form_Element_MultiCheckbox */ public function loadDefaultDecorators() { if ($this->loadDefaultDecoratorsIsDisabled()) { return $this; } parent::loadDefaultDecorators(); // Disable 'for' attribute if (false !== ($decorator = $this->getDecorator('label'))) { $decorator->setOption('disableFor', true); } return $this; }
public function render(Zend_View_Interface $view = null) { $value = $this->getValue(); $data = $this->build_tree(); $js = '$.include("/zkernel/ctl/rubr/rubr.js", function() { rubr.init("' . $this->getName() . '", { data: ' . Zend_Json::encode($data) . ' }); }); '; $js = str_replace(',}', '}', $js); $this->getView()->inlineScript('script', $js); return parent::render($view); }
/** * Определяем массив опций и дергаем родительский конструктор * * @param mixed $spec * @param array $options */ public function __construct($spec, $options = null) { $this->translate = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('Translate'); $this->elements = $this->getElements(); $this->configs = $this->getConfigs(); $this->forms = $this->getForms(); $this->renders = $this->getRenders(); /** * Формируем выпадающий список с типами элементов */ $options['multioptions'] = array(null => $this->translate->_('---Выберите---')); foreach ($this->configs as $fieldtype => $form) { $options['multioptions'][$fieldtype] = $form['label']; } /** * Инициализируем родительский конструктор */ parent::__construct($spec, $options); }
/** * Определяем массив записей, тип элемента и дергаем родительский конструктор * * @param mixed $spec * @param array $options */ public function __construct($spec, $options = null) { $translate = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('Translate'); $pairs = array(); /** * Определяем тип элемента * select, radio - одиночный выбор * multiselect, checkbox - множественный выбор */ $type = isset($options['type']) && in_array(strtolower($options['type']), array('select', 'multiselect', 'checkbox', 'radio')) ? strtolower($options['type']) : 'select'; switch ($type) { case 'multiselect': $this->helper = 'formSelect'; $this->_isArray = true; $this->multiple = 'multiple'; break; case 'checkbox': $this->helper = 'formMultiCheckbox'; $this->_isArray = true; $this->multiple = 'multiple'; break; case 'radio': $this->helper = 'formRadio'; break; default: $pairs = array(null => $translate->_('---Выберите---')); break; } /** * Добавляем записи из справочника на элемент */ if (isset($options['dictionaryid'])) { require_once 'Phorm/Dictionaries.php'; $Dictionaries = new Phorm_Dictionaries(); if (isset($options['multioptions']) && is_array($options['multioptions'])) { $pairs += $options['multioptions']; } $options['multioptions'] = $pairs + $Dictionaries->getEntriesListAsPairs($options['dictionaryid']); unset($options['dictionaryid']); } parent::__construct($spec, $options); }
/** * Is the value provided valid? * Sets flag RegisterInArrayValidator to false and executes the parent isValid * * @param string $value * @param mixed $context * @return bool */ public function isValid($value, $context = null) { $this->setRegisterInArrayValidator(false); return parent::isValid($value, $context); }
/** * Определяем массив разделов и дергаем родительский конструктор * * @param mixed $spec * @param array $options */ public function __construct($spec, $options = null) { /** * Определяем тип элемента * select, radio - одиночный выбор * multiselect, checkbox - множественный выбор */ $this->type = isset($options['type']) && in_array(strtolower($options['type']), array('select', 'multiselect', 'checkbox', 'radio')) ? strtolower($options['type']) : 'select'; if ($this->type == 'multiselect') { $this->_isArray = true; $this->multiple = 'multiple'; } if ($this->type == 'checkbox') { $this->_isArray = true; } /** * Переопределяем помощник вида при использовании Canonical и чекбоксов */ if ($this->type == 'checkbox' && isset($options['usecanonical']) && $options['usecanonical'] == true) { $this->helper = 'selectCanonical'; // Враппер к formCategories с добавлением JQuery-логики } /** * Манипуляция с разделами */ require_once "Phorm/Categories.php"; $Categories = new Phorm_Categories(); /** * Получаем список разделов */ if (isset($options['moduleid'])) { $CategoriesList = $Categories->getCategoriesPathsByModule($options['moduleid']); } else { $CategoriesList = $Categories->getList(); } /** * Собираем массив пар для мультиопций */ $pairs = isset($options['multioptions']) && is_array($options['multioptions']) ? $options['multioptions'] : array(); foreach ($CategoriesList as $category) { if (isset($options['moduleid']) && $category['moduleid'] != $options['moduleid']) { continue; } $pairs[$category['categoryid']] = $category['categoryname']; } /** * Добавляем разделы для визуализации вложенности в хелпере */ if (isset($options['multioptions']) && is_array($options['multioptions'])) { // Унифицируем опции, заданные в конфигурационном файле формы foreach ($options['multioptions'] as $key => $val) { if (is_string($val) && is_string($key)) { $options['multioptions'][$key] = array('categoryid' => $key, 'categoryname' => $val, 'clevel' => 0, 'visible' => 'yes'); } } $options['categories'] = $options['multioptions'] + $CategoriesList; } else { $options['categories'] = $CategoriesList; } /** * Добавляем мультиопции для валидации */ $options['multioptions'] = $pairs; /** * Инициализируем родительский конструктор */ parent::__construct($spec, $options); }
/** * Определяем массив опций и дергаем родительский конструктор * * @param mixed $spec * @param array $options */ public function __construct($spec, $options = null) { $this->translate = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('Translate'); /** * Получаем информацию о структуре или структурах */ if (isset($options['structures'])) { $options['structures'] = explode(',', $options['structures']); require_once 'Phorm/Structures.php'; $StructuresModel = new Phorm_Structures(); $structures = array(); $multioptions = array(); foreach ($options['structures'] as $key => $structureid) { if ($StructureInfo = $StructuresModel->getStructureFullInfo($structureid)) { $structures[$StructureInfo['structureid']] = $StructureInfo; } else { unset($options['structures'][$key]); } $multioptions[$StructureInfo['structureid']] = $StructureInfo['structurename']; $options['multioptions'] = $multioptions; } /** * Определяем шаблон формы для элементов структур */ $form_tpl = new Phorm_Form(null, null, array('elements' => $options['elements'])); /** * Создаем форму для каждой из структур */ require_once 'Phorm/Form.php'; foreach ($structures as $structure) { $form = new Phorm_Form(); $form->removeDecorator('Form'); $form->removeDecorator('DtDdWrapper'); foreach ($structure['groups'] as $group) { $form->setElementsBelongTo($spec . '[' . $structure['structureid'] . ']' . '[' . $group['groupid'] . ']'); /** * Добавляем элементы на форму * @todo Добавить обязательность заполнения */ $elements = array(); // массив элементов для добавления в DisplayGroup foreach ($group['properties'] as $property) { /** * Определяем тип используемого элемента */ $type = $property['propertytype']; $realtype = in_array($type, array('select', 'structure', 'dictionary')) && $property['ismultiple'] == 'yes' ? 'multiselect' : $type; if ($element = clone $form_tpl->getElement($realtype)) { // Устанавливаем имя и заголовок элемента $element->setLabel($property['propertyname'])->setName($property['propertyid']); // Допиливаем обычный селект if ($type == 'select' && !empty($property['propertyoptions'])) { $propertyoptions = array(); // ставим ключи массива опций в их значение foreach ($property['propertyoptions'] as $prop) { $propertyoptions[$prop] = $prop; } if ($property['ismultiple'] == 'no') { $propertyoptions = array(null => $this->translate->_('---Выберите---')) + $propertyoptions; } $element->setMultiOptions($propertyoptions); } // Допиливаем селект из другой структуры if ($type == 'structure' && $property['structureid'] > 0) { $propertyoptions = $StructuresModel->getStructureResourcesAsPairs($property['structureid']); if ($property['ismultiple'] == 'no') { $propertyoptions = array(null => $this->translate->_('---Выберите---')) + $propertyoptions; } $element->setMultiOptions($propertyoptions); } // Допиливаем селект из справочника if ($type == 'dictionary' && $property['dictionaryid'] > 0) { $DictionariesModel = new Phorm_Dictionaries(); $propertyoptions = $DictionariesModel->getEntriesListAsPairs($property['dictionaryid']); if ($property['ismultiple'] == 'no') { $propertyoptions = array(null => $this->translate->_('---Выберите---')) + $propertyoptions; } $element->setMultiOptions($propertyoptions); } $form->addElement($element); $elements[] = $property['propertyid']; } } /** * Если групп несколько, то добавляем DisplayGroup * @todo Добавить в опции возможность задавать css-классы */ if (count($structure['groups']) > 1) { $DisplayGroup = $form->addDisplayGroup($elements, 'group-' . $group['groupid'], array('legend' => $group['groupname'])); } } $this->forms[$structure['structureid']] = $form; $this->renderforms[$structure['structureid']] = $form->render(); } unset($options['elements']); } /** * Инициализируем родительский конструктор */ parent::__construct($spec, $options); }