コード例 #1
0
 public function Field($properties = array())
 {
     $source = $this->getSource();
     // Default value to best availabel locale
     $value = $this->Value();
     if ($this->config()->default_to_locale && (!$value || !isset($source[$value])) && $this->locale()) {
         $locale = new Zend_Locale();
         $locale->setLocale($this->locale());
         $value = $locale->getRegion();
         $this->setValue($value);
     }
     // Default to default country otherwise
     if (!$value || !isset($source[$value])) {
         $this->setValue($this->config()->default_country);
     }
     return parent::Field($properties);
 }
コード例 #2
0
 public function testStringOneValueSelectedOptionBehaviour()
 {
     $field = new DropdownField('Field', null, array('-1' => 'some negative', '0' => 'none', '1' => 'one', '2+' => 'two or more'), '1');
     $selectedOptions = $this->findSelectedOptionElements($field->Field());
     $this->assertEquals((string) $selectedOptions[0], 'one', 'The selected option is "one"');
     $field = new DropdownField('Field', null, array('-1' => 'some negative', '0' => 'none', '1' => 'one', '2+' => 'two or more'), 1);
     $selectedOptions = $this->findSelectedOptionElements($field->Field());
     $this->assertEquals((string) $selectedOptions[0], 'one', 'The selected option is "one"');
 }