_getData('class'); $this->addElement( 'select', 'year', array( 'label' => 'Year', 'required' => true, 'multiOptions' => array('' => 'Select One') + App_Award_Admin_Obj::getYears4Select() ) ); $this->addElement( 'radio', 'class', array( 'label' => 'Class', 'multiOptions' => App_Award_Admin_Obj::getClass4Select(), 'required' => true, 'separator' => ' | ', 'onclick' => 'this.blur()', 'onchange' => "appAward.changeClass(this.value);", 'value' => 'none' ) ); $this->_initChapterAwardsElements($class); $this->_initNationalAwardsElements($class); $this->addElement( 'htmlEditor', 'description', array('label' => 'Description', 'required' => true, 'hasMsWordNote' => true) ); return $this; } private function _initNationalAwardsElements($class) { $required = (!$this->isSubmitted() || App_Award_Admin_Obj::CLASS_NATIONAL == $class); $employerRequired = $required && App_Award_Abstract_Obj::TYPE_PROFESSIONAL != $this->_getData('nationalType'); $this->addElement( 'select', 'nationalType', array( 'label' => 'Type', 'required' => $required, 'multiOptions' => array('' => 'Select One') + App_Award_Admin_Obj::getNationalType4Select() ) ); $this->addElement('text', 'nationalAwardName', array('label' => 'Name of Award', 'required' => $required)); $this->addElement('text', 'nationalWinner', array('label' => 'Award Winner', 'required' => $required)); $this->addElement('text', 'nationalEmployer', array('label' => 'Employer', 'required' => $employerRequired)); $this->addElement('text', 'nationalEndeavor', array('label' => 'Endeavor')); $requiredFields = array('nationalType', 'nationalAwardName', 'nationalWinner', 'nationalEmployer'); foreach ($requiredFields as $element) { $this->{$element}->getDecorator('Label')->setOption('class', 'required'); } } private function _initChapterAwardsElements($class) { $required = (!$this->isSubmitted() || App_Award_Admin_Obj::CLASS_CHAPTER == $class); $chapterAwardNameId = $this->_getData('chapterAwardNameId'); $hugoRequired = $required && 'hugoEricksonAward' == $chapterAwardNameId; $projectRequired = $required && in_array($chapterAwardNameId, [ 'projectYear', 'projectYearTransportation', 'projectYearStructures', 'projectYearEnvironment', 'projectYearRestoration', 'projectYearRepair', 'projectYearOutstate', ]); $config = Qs_Application::getConfig('award'); $this->addElement( 'select', 'chapterAwardNameId', array( 'label' => 'Name of Award', 'required' => $required, 'multiOptions' => array('' => 'Select One') + App_Cms_Obj::getInstance()->getDAwardChapterName4Select() ) ); $this->addElement('text', 'winner', array('label' => 'Award Winner', 'required' => $required)); $resizeSizes = $config->imagePeople->width . 'x' . $config->imagePeople->height; if (in_array( $chapterAwardNameId, [ 'projectYear', 'projectYearTransportation', 'projectYearStructures', 'projectYearEnvironment', 'projectYearRestoration', 'projectYearRepair', 'projectYearOutstate', 'environmentalStewardshipAward' ] )) { $resizeSizes = $config->image->width . 'x' . $config->image->height; } $this->addElement( 'extendedImage', 'photo', array( 'label' => 'Photo', 'required' => App_Award_Admin_Obj::CLASS_CHAPTER == $class, 'resize' => $resizeSizes . $config->image->resizeMethodAlias, ) ); $this->addElement('text', 'employer', array('label' => 'Employer', 'required' => $hugoRequired)); $requiredFields = array( 'chapterAwardNameId', 'winner', 'photo', 'employer', ); foreach ($requiredFields as $element) { $this->{$element}->getDecorator('Label')->setOption('class', 'required'); } } public function render(Zend_View_Interface $view = null) { /** @var $doc Qs_Doc */ $doc = Zend_Registry::get('doc'); $doc->addScript('js/app/admin-award.js'); $defaultClass = $this->_getData('class') ? $this->_getData('class') : 'none'; $existsClasses = array( 'national' => App_Award_Admin_Obj::CLASS_NATIONAL, 'chapter' => App_Award_Admin_Obj::CLASS_CHAPTER, 'none' => 'none' ); $options = array( 'formId' => $this->getId(), 'class' => $defaultClass, 'existsClasses' => $existsClasses, 'imageSizes' => App_Award_Abstract_Obj::getImageSizes() ); $doc->addInitFunction('initAppAward', array($options)); return parent::render($view); } }