_date = $date; return $this; } /** * @return mixed */ public function getDate() { return $this->_date; } /** * @param mixed $showDay * @return $this */ public function setShowDay($showDay) { $this->_showDay = $showDay; return $this; } /** * @return mixed */ public function getShowDay() { return $this->_showDay; } protected function _initElements() { if ($this->_showDay) { $this->addElement('static', 'day', ['label' => 'Day', 'value' => (int) $this->getName() + 1]); $this->addElement('static', 'dayFriendlyName', ['label' => 'Date', 'value' => $this->_getDayFriendlyName()]); } $this->addElement( 'time', 'startTime', ['label' => 'Start Time', 'required' => true, 'emptyOptions' => true] ); $this->addElement( 'time', 'endTime', ['label' => 'End Time', 'required' => true, 'emptyOptions' => true] ); $startTime = $this->getElement('startTime'); $endTime = $this->getElement('endTime'); $endTime->addValidator( 'Compare', true, [ 'callback' => [$startTime, 'getValue'], 'operator' => '>', 'messages' => $endTime->getLabel() . ' should be greater than ' . $startTime->getLabel(), ] ); return $this; } protected function _getDayFriendlyName() { return date('l, F j', strtotime($this->_date)); } public function addElement($element, $name = null, $options = null) { $options['decorators'] = [ 'ViewHelper', 'Errors', 'Description', [ 'HtmlTag', [ 'tag' => 'td', 'class' => 'c_' . $name, 'id' => ['callback' => ['Zend_Form_Element', 'resolveElementId']], ], ], ]; return parent::addElement($element, $name, $options); } public function loadDefaultDecorators() { if ($this->loadDefaultDecoratorsIsDisabled()) { return $this; } $decorators = $this->getDecorators(); if (empty($decorators)) { $this->addDecorator('FormElements') ->addDecorator('HtmlTag', ['tag' => 'tr']); } return $this; } }