Exemplo n.º 1
0
 public function populate($data)
 {
     if (isset($data['id'])) {
         $this->_city->setId($data['id']);
     }
     $this->_city->setName($data['name']);
     if (isset($data['state_id'])) {
         $dc = new Location_Domain_State();
         $c = $dc->getById($data['state_id']);
         $this->_city->setState($c);
     }
 }
Exemplo n.º 2
0
 private function _addElementState()
 {
     $this->addElement('select', 'state_id', array('required' => true, 'label' => 'State', 'dimension' => 4));
     $el = $this->getElement('state_id');
     $cd = new Location_Domain_State();
     $c = $cd->getAll('name');
     $el->addMultiOption(null, null);
     foreach ($c as $state) {
         $el->addMultiOption($state->getId(), $state->getName());
     }
     if ($this->_model && $this->_model->state_id) {
         $el->setValue($this->_model->state_id);
     }
 }
Exemplo n.º 3
0
 public function getBornState()
 {
     if (!$this->bornState) {
         $domain = new Location_Domain_State();
         $this->bornState = $domain->getById($this->born_state_id);
     }
     return $this->bornState;
 }
Exemplo n.º 4
0
 /**
  * Adds an element StateId.<br/>
  * Defaults:<br/>
  * name         = state_id<br/>
  * requires     = false<br/>
  * label        = State<br/>
  * placeholder  = 'Choose a state'<br/>
  * dimension    = 4<br/>
  * modelfield   = state_id<br/>
  * 
  * @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 addElementStateId($form, $options = array())
 {
     $elementName = isset($options['name']) ? $options['name'] : 'state_id';
     $modelField = isset($options['modelfield']) ? $options['modelfield'] : 'state_id';
     $form->addElement('select', $elementName, array('filters' => array('StringTrim'), 'label' => isset($options['label']) ? $options['label'] : 'State', 'dimension' => isset($options['dimension']) ? $options['dimension'] : 4, 'placeholder' => 'Choose a state', 'required' => isset($options['required']) ? $options['required'] : false, 'value' => $this->_model ? $this->_model->{$modelField} : ''));
     $el = $form->getElement($elementName);
     $cd = new Location_Domain_State();
     $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);
     }
 }