/** * @return array */ public function getValueOptions() { if (empty($this->valueOptions)) { $this->valueOptions = array(); foreach (DateTimeZone::listIdentifiers() as $id) { $names = explode('/', $id, 2); if (isset($names[1])) { if (empty($this->valueOptions[$names[0]]['label'])) { $this->valueOptions[$names[0]]['label'] = $names[0]; } $this->valueOptions[$names[0]]['options'][$id] = str_replace(array('/', '_'), array(' / ', ' '), $names[1]); } else { $this->valueOptions = array_merge(array($id => $id), $this->valueOptions); } } } return parent::getValueOptions(); }
/** * Retrieve the element value * * @return mixed */ public function getValue() { if (empty($this->value) && !empty($this->attributes['required'])) { $locale = $this->getServiceLocator()->get('Locale'); $available = $locale->getAvailableFlags(); if ($this->onlyEnabledLocales) { $available = array_filter($available); } if (isset($available[$current = $locale->getCurrent()])) { $this->value = $current; } else { if (isset($available[$default = $locale->getDefault()])) { $this->value = $default; } else { if (isset($available[$fallback = $locale->getFallback()])) { $this->value = $fallback; } } } } return parent::getValue(); }