/** * Set the countries available. * * @param T_Geo_CountryGateway $countries * @param string $default default country code (e.g. GB) * @return T_Form_Address fluent interface */ function setCountries(T_Geo_CountryGateway $countries, $default = 'GB') { $this->countries = $countries; // add (or overwrite) form element $world = $countries->getAll(); $options = array(); foreach ($world as $c) { $options[$c->getCode()] = $c->getName(); } $country = new T_Form_Select($this->getAlias() . '_country', 'Country'); $country->setOptions($options)->setDefault($default); $this->addChild($country, $this->getAlias() . '_country'); return $this; }
/** * Gets a new instance of the select element. * * @param string $alias element alias * @param string $label element label * @return T_Form_Select text input to test. */ function getInputElement($alias, $label) { $input = new T_Form_Select($alias, $label); $input->setOptions(array('value1' => 'Label 1', 'value2' => 'Label 2', 'value3' => 'Label 3')); return $input; }
/** * Get the test element. * * @return T_Form_Upload */ function getElement($name, $label) { $element = new T_Form_Select($name, $label); $element->setOptions(array('test' => '1', 'dave' => 'fred', 'swadg' => 'asdgf')); return $element; }