Пример #1
0
 public function initialize($entity = null, $options = null)
 {
     $country = new Select('countryid', Country::find(), array('using' => array('id', 'country'), 'useEmpty' => TRUE, 'emptyText' => $this->di->get('translate')->_('Seleccione un País')));
     $country->setLabel('País');
     $this->add($country);
     if (isset($entity)) {
         if ($entity->getCountryid()) {
             $state = new Select('stateid', State::find(array("columns" => array("id,state"), "conditions" => "countryid =:countryid:", "bind" => array("countryid" => $entity->countryid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione un Estado'), 'using' => array('id', 'state')));
             $state->setLabel('Estado');
             $this->add($state);
             $city = new Select('cityid', City::find(array("columns" => array("id,city"), "conditions" => "countryid =:countryid: AND stateid =:stateid: ", "bind" => array("countryid" => $entity->countryid, "stateid" => $entity->stateid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione una ciudad'), 'using' => array('id', 'city')));
             $city->setLabel('Ciudad');
             $this->add($city);
             $township = new Select('townshipid', Township::find(array("columns" => array("id,township"), "conditions" => "cityid =:cityid:", "bind" => array("cityid" => $entity->cityid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione un Sector'), 'using' => array('id', 'township')));
             $township->setLabel('Sector');
             $this->add($township);
             $neighborhood = new Select('neighborhoodid', Neighborhood::find(array("columns" => array("id,neighborhood"), "conditions" => "cityid =:cityid:", "bind" => array("cityid" => $entity->cityid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione un Barrio'), 'using' => array('id', 'neighborhood')));
             $neighborhood->setLabel('Barrio');
             $this->add($neighborhood);
         } else {
             $this->set_empty_values();
         }
     } else {
         $this->set_empty_values();
     }
     $address = new Textarea('address', array("maxlength" => "400"));
     $address->setLabel('Dirección');
     $this->add($address);
     $description = new Textarea('description', array("maxlength" => "100"));
     $description->setLabel('Descripción');
     $this->add($description);
 }
Пример #2
0
 public function initialize($entity = null, $options = null)
 {
     $city = new Select('cityid', City::find(), array('using' => array('id', 'city'), 'useEmpty' => TRUE, 'emptyText' => 'Seleccione una Ciudad'));
     $city->setLabel('Ciudad');
     $this->add($city);
     //var_dump($entity->townshipid);
     if (isset($entity)) {
         $township = new Select('townshipid', Township::find(array("columns" => array("id,township"), "conditions" => "cityid =:cityid:", "bind" => array("cityid" => $entity->cityid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione un Sector'), 'using' => array('id', 'township')));
         $township->setLabel('Sector');
         $this->add($township);
     } else {
         $township = new Select('townshipid', array(), array('useEmpty' => TRUE, 'emptyText' => $this->di->get('translate')->_('Seleccione un Sector')));
         $township->setLabel('Sector');
         $this->add($township);
     }
     $countryvalue = "";
     $statevalue = "";
     $city = "";
     if (isset($entity)) {
         if ($entity->getCity()) {
             $countryvalue = $entity->getCity()->getCountry()->getCountry();
             $statevalue = $entity->getCity()->getState()->getState();
         }
     }
     $country = new Text('country');
     $country->setLabel('País');
     $country->setDefault($countryvalue);
     $this->add($country);
     $state = new Text('state');
     $state->setDefault($statevalue);
     $state->setLabel('Estado');
     $this->add($state);
     $neighborhood = new Text('neighborhood');
     $neighborhood->setLabel('Barrio');
     $this->add($neighborhood);
     //añadimos un botón de tipo submit
     $submit = $this->add(new Submit('Guardar', array('class' => 'btn btn-success')));
 }
 /**
  * @Route("/get_township_data/{cityid}", methods={"POST"}, name="get_township_data")
  */
 public function get_township_dataAction($cityid)
 {
     $this->view->disable();
     $citydata = $this->get_citydata($cityid);
     $townshipdata = Township::findBycityid($cityid)->toArray();
     $data = array('township' => $townshipdata, 'citydata' => $citydata);
     echo json_encode($data);
 }
 /**
  * @Route("/get_township_data/{cityid}", methods={"POST"}, name="get_township_data")
  */
 public function get_township_dataAction($cityid)
 {
     $this->view->disable();
     $townshipdata = Township::findBycityid($cityid)->toArray();
     echo json_encode($townshipdata);
 }