private function _addElementCIty() { $this->addElement('select', 'city_id', array('required' => true, 'label' => 'City', 'dimension' => 4)); $el = $this->getElement('city_id'); $cd = new Location_Domain_City(); $c = $cd->getAll('name'); foreach ($c as $city) { $el->addMultiOption($city->getId(), $city->getName()); } if ($this->_model && $this->_model->city_id) { $el->setValue($this->_model->city_id); } }
protected function _addElementCity() { $this->addElement('select', 'city_id', array('required' => false, 'label' => 'City', 'dimension' => 4, 'placeholder' => 'Choose a city')); $el = $this->getElement('city_id'); $cd = new Location_Domain_City(); $c = $cd->getAll(array('orderby' => 'name')); foreach ($c as $city) { $el->addMultiOption($city->getId(), $city->getName()); } if ($this->_model && $this->_model->city_id) { $el->setValue($this->_model->city_id); } else { $el->setValue(-1); } }
public function populate($data) { if (is_null($this->_busunit)) { $this->_busunit = new Busunit_Model_Busunit(); } Agana_Data_BeanUtil::populate($this->_busunit, $data); if (isset($data['id'])) { $this->_busunit->setId($data['id']); } if (isset($data['city_id'])) { $dc = new Location_Domain_City(); $c = $dc->getById($data['city_id']); $this->_busunit->setCity($c); } }
public function populate($data) { if (isset($data['id'])) { $this->_region->setId($data['id']); } $this->_region->setName($data['name']); if (isset($data['city_id'])) { $dc = new Location_Domain_City(); $c = $dc->getById($data['city_id']); $this->_region->setCity($c); $this->_region->setCity_id($data['city_id']); } if (isset($data['parent_id'])) { if (is_numeric($data['parent_id'])) { $dc = new Location_Domain_CityRegion(); $c = $dc->getById($data['parent_id']); $this->_region->setParent($c); $this->_region->setParent_id($data['parent_id']); } } }
public function getBornCity() { if (!$this->bornCity) { $domain = new Location_Domain_City(); $this->bornCity = $domain->getById($this->born_city_id); } return $this->bornCity; }
/** * Adds an element CityId. * Defaults: * name = city_id * requires = false * label = City * placeholder = 'Choose a city' * dimension = 4 * modelfield = city_id * * @param Zend_Form $form The Zend_Form object where the element will be added * @param array $options The options to pass in the element */ public function addElementCityId($form, $options = array()) { $elementName = isset($options['name']) ? $options['name'] : 'city_id'; $modelField = isset($options['modelfield']) ? $options['modelfield'] : 'city_id'; $form->addElement('select', $elementName, array('filters' => array('StringTrim'), 'label' => isset($options['label']) ? $options['label'] : 'City', 'dimension' => isset($options['dimension']) ? $options['dimension'] : 4, 'placeholder' => 'Choose a city', 'required' => isset($options['required']) ? $options['required'] : false, 'value' => $this->_model ? $this->_model->{$modelField} : '')); $el = $form->getElement($elementName); $cd = new Location_Domain_City(); $c = $cd->getAll(array('orderby' => 'name')); $el->addMultiOption(null, null); foreach ($c as $city) { $el->addMultiOption($city->getId(), $city->getName()); } if ($this->_model && $this->_model->{$modelField}) { $el->setValue($this->_model->{$modelField}); } else { $el->setValue(null); } }
public function getCity() { if (is_null($this->city_id) || !is_numeric($this->city_id)) { $this->city = new Location_Model_City(); } else { if (is_null($this->city)) { $domain = new Location_Domain_City(); $this->city = $domain->getById($this->city_id); } } return $this->city; }