public function init() { parent::init(); if (!$this->getHmHomeId()) { throw new Exception(); } $element = new Zend_Form_Element_Select('year'); $element->setLabel('Jaar')->setRequired(true)->addMultiOption('', '...'); $percentages = Model_Hm_Day_Percentage::findAllByHomeId($this->_hmHomeId)->execute(null, Doctrine_Core::HYDRATE_ARRAY); $availableYears = new Model_Hm_AvailableYears($percentages, 5); foreach ($availableYears->toArray() as $year) { $element->addMultiOption($year, $year); } $this->addElement($element); $elements[] = 'year'; for ($i = 1; $i <= 7; $i++) { $elementName = $this->_labelTemplates[$i]; $elements[] = 'day_' . $i; $element = new Zend_Form_Element_Text('day_' . $i); $element->setLabel($elementName)->setRequired(true)->setAttribs(array('maxlength' => 6))->setValidators(array(array('float'), array('stringLength', false, array('max' => 6)))); $this->addElement($element); } $this->addDisplayGroup($elements, 'days', array('legend' => 'Percentage')); $element = new Zend_Form_Element_Submit('submit_percentageday'); $element->setLabel('Verwerken')->setAttrib('class', 'submit'); $this->addElement($element); $this->addDisplayGroup(array('submit_percentageday'), 'submit', array('class' => 'submit')); $this->bhvkDecorators(); $this->bhvkDecorateSubmitElement($this->getElement('submit_percentageday')); }
/** * Initializing form */ public function init() { parent::init(); $element = new Zend_Form_Element_Select('year'); $element->setLabel('Jaar')->addMultiOption('', '...')->setDescription('Percentages zijn van toepassing op dit jaartal')->setRequired(true); $entries = Model_Hm_Week_Percentage::findAllByHomeId($this->getHomeId())->select('wp.year, wp.id, wp.hm_home_id')->execute(null, Doctrine_Core::HYDRATE_ARRAY); $availableYears = new Model_Hm_AvailableYears($entries); foreach ($availableYears->toArray() as $year) { $element->addMultiOption($year, $year); } $this->addElement($element); $this->addDisplayGroup(array('year'), 'year-group', array('legend' => 'Algemeen', 'class' => 'width100')); for ($weekNo = 01; $weekNo <= 53; $weekNo++) { $elementName = 'week_' . $weekNo; $elements[] = $elementName; $element = new Zend_Form_Element_Text($elementName); $element->setLabel('Percentage')->setValidators(array(array('Float')))->setAttribs(array('maxlength' => 6))->setRequired(true); $this->addElement($element); $this->addDisplayGroup(array($elementName), $elementName . 'group', array('class' => 'weekpercentage', 'legend' => 'Week ' . $weekNo)); } $element = new Zend_Form_Element_Submit('submit_percentageweek'); $element->setLabel('Verwerken')->setAttrib('class', 'submit'); $this->addElement($element); $this->addDisplayGroup(array('submit_percentageweek'), 'submit', array('class' => 'submit')); $this->bhvkDecorators(); $this->bhvkDecorateSubmitElement($this->getElement('submit_percentageweek')); }