data_dependant = $data_dependant; if(!$this->locale) { $this->locale = i18n::get_locale(); } parent::__construct($name, $title, $value, 6, $form); } function Field() { $this->addExtraClass('DatePickerField'); Requirements::block(SAPPHIRE_DIR .'/thirdparty/jquery/jquery.js'); Requirements::javascript('themes/openstack/javascript/jquery-2.0.3.min.js'); Requirements::javascript('themes/openstack/javascript/jquery-migrate-1.2.1.min.js'); Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js'); Requirements::javascript("datepicker/javascript/datepicker.js"); $attributes = array( 'type' => 'text', 'class' => 'text' . ($this->extraClass() ? $this->extraClass() : ''), 'id' => $this->id(), 'name' => $this->Name(), 'value' => $this->Value(), 'tabindex' => $this->getTabIndex(), 'maxlength' => ($this->maxLength) ? $this->maxLength : null, 'size' => ($this->maxLength) ? min( $this->maxLength, 10 ) : null, ); if(!empty($this->data_dependant)){ $attributes["data-dependant-on"] = $this->data_dependant; } if($this->disabled) $attributes['disabled'] = 'disabled'; return $this->createTag('input', $attributes); } /** * Sets the internal value to ISO date format. * * @param String|Array $val */ function setValue($val) { if(empty($val)) { $this->value = null; $this->valueObj = null; } else { // Quick fix for overzealous Zend validation, its case sensitive on month names (see #5990) if(is_string($val)) $val = ucwords(strtolower($val)); // load ISO date from database (usually through Form->loadDataForm()) if(!empty($val) && Zend_Date::isDate($val, 'yyyy-MM-dd')) { $this->valueObj = new Zend_Date($val, 'yyyy-MM-dd'); $this->value = $this->valueObj->get('yyyy-MM-dd', $this->locale); } else { $this->value = $val; $this->valueObj = null; } } } /** * @return String ISO 8601 date, suitable for insertion into database */ function dataValue() { if($this->valueObj) { return $this->valueObj->toString('yyyy-MM-dd'); } else { return null; } } }