/** * Called after the check that all required registry values * have been set correctly has run. * * @return void */ public function afterRegistry() { parent::afterRegistry(); if ($this->loadDefault) { $this->loadDefaultElements(); } }
public function createTemplateSelectElement($name, $label, $target = false, $list = false, $onChangeSubmit = false) { $options['label'] = $label; $query = 'SELECT gems__comm_templates.gct_id_template, gems__comm_templates.gct_name FROM gems__comm_template_translations RIGHT JOIN gems__comm_templates ON gems__comm_templates.gct_id_template = gems__comm_template_translations.gctt_id_template WHERE gems__comm_template_translations.gctt_subject <> "" AND gems__comm_template_translations.gctt_body <> ""'; if ($target) { $query .= ' AND gems__comm_templates.gct_target = ?'; } $query .= ' GROUP BY gems__comm_templates.gct_id_template'; if ($target) { $options['multiOptions'] = $this->db->fetchPairs($query, $target); } else { $options['multiOptions'] = $this->db->fetchPairs($query); } if (!$list) { $options['multiOptions'] = array('' => '') + $options['multiOptions']; } if ($onChangeSubmit) { $options['onchange'] = 'this.form.submit()'; } if ($list) { $options['required'] = true; $options['size'] = min(count($options['multiOptions']) + 1, 7); } return $this->_form->createElement('select', $name, $options); }
/** * The form for selecting the patch level * * @return \Gems_Form */ protected function _getSelectForm() { $form = new \Gems_Form(array('name' => 'autosubmit', 'class' => 'form-inline', 'role' => 'form')); $form->setHtml('div'); $div = $form->getHtml(); $div->class = 'search'; $span = $div->div(array('class' => 'panel panel-default'))->div(array('class' => 'inputgroup panel-body')); $element = $form->createElement('select', 'gpa_level', array('multiOptions' => $this->patchLevels, 'onchange' => 'this.form.submit();', 'onkeyup' => 'this.form.submit();')); $element->setValue($this->getPatchLevel()); $span->input($element); $form->addElement($element); $submit = $form->createElement('submit', 'search', array('label' => $this->_('Search'), 'class' => 'button small')); $span->input($submit); $form->addElement($submit); return $form; }
/** * Fix the decorators the first time we try to render the form * * @param \Zend_View_Interface $view * @return string */ public function render(\Zend_View_Interface $view = null) { if ($this->_getIsRendered()) { return; } $this->fixDecorators(); return parent::render($view); }
/** * Add form elements when a responseDatabase is present * @param \Gems_Form $form existing form type * @param array data existing options set in the form * @return array of form elements */ protected function addResponseDatabaseForm($form, &$data, &$elements) { if (isset($data['tid']) && !empty($data['tid'])) { // If we have a responsedatabase and a track id, try something cool ;-) $responseDb = $this->project->getResponseDatabase(); if ($this->db === $responseDb) { // We are in the same database, now put that to use by allowing to filter respondents based on an answer in any survey $empty = $this->util->getTranslated()->getEmptyDropdownArray(); $allSurveys = $empty + $this->util->getDbLookup()->getSurveysForExport(); $element = new \Zend_Form_Element_Select('filter_sid'); $element->setLabel($this->_('Survey'))->setMultiOptions($allSurveys); $groupElements = array($element); if (isset($data['filter_sid']) && !empty($data['filter_sid'])) { $filterSurvey = $this->loader->getTracker()->getSurvey($data['filter_sid']); $filterQuestions = $empty + $filterSurvey->getQuestionList($this->locale->getLanguage()); $element = new \Zend_Form_Element_Select('filter_answer'); $element->setLabel($this->_('Question'))->setMultiOptions($filterQuestions); $groupElements[] = $element; } if (isset($filterSurvey) && isset($data['filter_answer']) && !empty($data['filter_answer'])) { $questionInfo = $filterSurvey->getQuestionInformation($this->locale->getLanguage()); if (array_key_exists($data['filter_answer'], $questionInfo)) { $questionInfo = $questionInfo[$data['filter_answer']]; } else { $questionInfo = array(); } if (array_key_exists('answers', $questionInfo) && is_array($questionInfo['answers']) && count($questionInfo['answers']) > 1) { $element = new \Zend_Form_Element_Multiselect('filter_value'); $element->setMultiOptions($empty + $questionInfo['answers']); $element->setAttrib('size', count($questionInfo['answers']) + 1); } else { $element = new \Zend_Form_Element_Text('filter_value'); } $element->setLabel($this->_('Value')); $groupElements[] = $element; } $form->addDisplayGroup($groupElements, 'filter', array('showLabels' => true, 'Description' => $this->_('Filter'))); array_shift($elements); } } }
/** * Creates a fake form so that it is (slightly) easier to * copy and paste a token. * * @param string $value Gems token value * @return \Gems_Form */ public static function makeFakeForm($value) { $form = new \Gems_Form(); $form->removeDecorator('HtmlTag'); $element = new \Zend_Form_Element_Text('gto_id_token'); $element->class = 'token_copy'; $element->setDecorators(array('ViewHelper', array('HtmlTag', 'Div'))); $form->addElement($element); $form->isValid(array('gto_id_token' => \MUtil_Lazy::call('strtoupper', $value))); return $form; }
/** * Constructs the form * * @param boolean $hideGroup When true group checkbox is hidden * @return \Gems_Form_TableForm */ public function getForm($hideGroup = false) { $form = new \Gems_Form(); $form->setAttrib('target', '_blank'); if ($hideGroup) { $element = new \Zend_Form_Element_Hidden('group'); } else { $element = new \Zend_Form_Element_Checkbox('group'); $element->setLabel($this->_('Group surveys')); } $element->setValue(1); $form->addElement($element); $element = new \Zend_Form_Element_Select('format'); $element->setLabel($this->_('Output format')); $outputFormats = array('html' => 'HTML'); if ($this->_pdf->hasPdfExport()) { $outputFormats['pdf'] = 'PDF'; $element->setValue('pdf'); } $element->setMultiOptions($outputFormats); $form->addElement($element); $element = new \Zend_Form_Element_Submit('export'); $element->setLabel($this->_('Export'))->setAttrib('class', 'button'); $form->addElement($element); $links = $this->menu->getMenuList(); $links->addParameterSources($this->request, $this->menu->getParameterSource()); $links->addCurrentParent($this->_('Cancel')); if (count($links)) { $element = new \MUtil_Form_Element_Html('menuLinks'); $element->setValue($links); // $element->setOrder(999); $form->addElement($element); } return $form; }
/** * Retrieve all form element values * * Fix for ZF error where subform values will be pushed into an array with key: formname * for compatibility both are now in the result array * * @param bool $suppressArrayNotation * @return array */ public function getValues($suppressArrayNotation = false) { $values = parent::getValues($suppressArrayNotation); foreach ($this->getSubForms() as $key => $subForm) { $values = $this->_array_replace_recursive($values, $values[$key]); } return $values; }