Пример #1
0
 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);
     }
 }
Пример #2
0
 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);
     }
 }
Пример #3
0
 /**
  * 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);
     }
 }