Displays the edit country state page
@param string $country_code
@param integer|null $state_id
515777
public function editCountryState($country_code, $state_id = null)
    {
        $this->setCountryState($state_id);
        $this->setCountry($country_code);
        $this->setTitleEditCountryState();
        $this->setBreadcrumbEditCountryState();

        $this->setData('state', $this->data_state);
        $this->setData('country', $this->data_country);
        $this->setData('zones', $this->getZonesCountryState());
        $this->setData('can_delete', $this->canDeleteCountryState());

        $this->submitEditCountryState();
        $this->outputEditCountryState();
    }
467964
public function findByCountryAndModule(Country $country, Module $module, State $state = null)
    {
        $response = null;

        $countryInAreaList = CountryAreaQuery::findByCountryAndState($country, $state);

        /** @var CountryArea $countryInArea */
        foreach ($countryInAreaList as $countryInArea) {
            $response = self::create()->filterByAreaId($countryInArea->getAreaId())
                ->filterByModule($module)
                ->findOne()
            ;

            if ($response !== null) {
                break;
            }
        }

        return $response;
    }
1004071
public function update(CountryRequest $request, Country $country)
    {
        $country->update($request->all());

        return redirect()->route('admin.country.index');
    }
209227
public function editField($field_id = null)
    {
        $this->setField($field_id);
        $this->setTitleEditField();
        $this->setBreadcrumbEditField();

        $this->setData('field', $this->data_field);
        $this->setData('types', $this->field->getTypes());
        $this->setData('can_delete', $this->canDeleteField());
        $this->setData('widget_types', $this->field->getWidgetTypes());
        $this->setData('languages', $this->language->getList(array('enabled' => true)));

        $this->submitEditField();
        $this->outputEditField();
    }
609846
protected function validateEditCountry()
    {
        $this->setSubmitted('country');
        $this->setSubmittedBool('status');
        $this->setSubmitted('update', $this->data_country);

        $this->validateComponent('country');

        return !$this->hasErrors();
    }
727882
public function editProduct($product_id = null)
    {
        $this->setProduct($product_id);
        $this->setTitleEditProduct();
        $this->setBreadcrumbEditProduct();

        $this->setData('product', $this->data_product);
        $this->setData('size_units', $this->convertor->getUnitNames('size'));
        $this->setData('weight_units', $this->convertor->getUnitNames('weight'));
        $this->setData('default_currency', $this->currency->getDefault());
        $this->setData('subtract_default', $this->config->get('product_subtract', 0));
        $this->setData('classes', $this->product_class->getList(array('status' => 1)));
        $this->setData('languages', $this->language->getList(array('enabled' => true)));

        $this->submitEditProduct();

        $this->setDataFieldsEditProduct();
        $this->setDataAuthorEditProduct();
        $this->setDataRelatedEditProduct();
        $this->setDataCategoriesEditProduct();
        $this->setDataImagesEditProduct();

        $this->setJsEditProduct();
        $this->outputEditProduct();
    }
1167518
protected function wizardAddState()
    {
        $this->validatePrompt('code', $this->text('Code'), 'state');
        $this->validatePrompt('name', $this->text('Name'), 'state');
        $this->validatePrompt('country', $this->text('Country'), 'state');
        $this->validatePrompt('zone_id', $this->text('Zone'), 'state', 0);
        $this->validatePrompt('status', $this->text('Status'), 'state', 0);

        $this->validateComponent('state');
        $this->addState();
    }
198350
def match_state_for_country( value, country_id )  ## NB: required country_id 
    if value =~ /^state:/   ## state:
      state_key = value[6..-1]  ## cut off state: prefix
      state = WorldDb::Model::State.find_by_key_and_country_id!( state_key, country_id )
      yield( state )
      true  # bingo - match found
    elsif is_state?( value )  ## assume state code e.g. TX or N
      state = WorldDb::Model::State.find_by_key_and_country_id!( value.downcase, country_id )
      yield( state )
      true  # bingo - match found
    else
      false # no match found
    end
  end
863491
public function view($id = null) {
		$country = $this->Countries->get($id);

		$this->set(compact('country'));
	}
155368
protected function setCountryState($state_id)
    {
        $this->data_state = array();

        if (is_numeric($state_id)) {

            $this->data_state = $this->state->get($state_id);

            if (empty($this->data_state)) {
                $this->outputHttpStatus(404);
            }
        }
    }
463227
function display_add_field($recordid = 0, $formdata = null) {
        global $CFG, $DB, $OUTPUT;

        $lat = '';
        $long = '';
        if ($formdata) {
            $fieldname = 'field_' . $this->field->id . '_0';
            $lat = $formdata->$fieldname;
            $fieldname = 'field_' . $this->field->id . '_1';
            $long = $formdata->$fieldname;
        } else if ($recordid) {
            if ($content = $DB->get_record('data_content', array('fieldid'=>$this->field->id, 'recordid'=>$recordid))) {
                $lat  = $content->content;
                $long = $content->content1;
            }
        }
        $str = '<div title="'.s($this->field->description).'">';
        $str .= '<fieldset><legend><span class="accesshide">'.$this->field->name.'</span></legend>';
        $str .= '<table class="form-inline"><tr><td align="right">';
        $classes = 'mod-data-input form-control-static';
        $str .= '<label for="field_'.$this->field->id.'_0" class="' . $classes . '">' . get_string('latitude', 'data');
        if ($this->field->required) {
            $str .= $OUTPUT->pix_icon('req', get_string('requiredelement', 'form'));
        }
        $classes = 'form-control mx-1';
        $str .= '</label></td><td>';
        $str .= '<input class="' . $classes . '" type="text" name="field_'.$this->field->id.'_0" ';
        $str .= ' id="field_'.$this->field->id.'_0" value="';
        $str .= s($lat).'" size="10" />°N</td></tr>';
        $classes = 'mod-data-input form-control-static';
        $str .= '<tr><td align="right"><label for="field_'.$this->field->id.'_1" class="' . $classes . '">';
        $str .= get_string('longitude', 'data');
        if ($this->field->required) {
            $str .= $OUTPUT->pix_icon('req', get_string('requiredelement', 'form'));
        }
        $classes = 'form-control mx-1';
        $str .= '</label></td><td><input class="' . $classes . '" type="text" ';
        $str .= 'name="field_'.$this->field->id.'_1" id="field_'.$this->field->id.'_1" value="';
        $str .= s($long).'" size="10" />°E</td>';
        $str .= '</tr>';
        $str .= '</table>';
        $str .= '</fieldset>';
        $str .= '</div>';
        return $str;
    }
1290404
public function edit($id = null) {
		$country = $this->Countries->get($id);

		if ($this->Common->isPosted()) {
			$country = $this->Countries->patchEntity($country, $this->request->getData());
			if ($this->Countries->save($country)) {
				$name = $country['name'];
				$this->Flash->success(__('record edit {0} saved', h($name)));
				return $this->redirect(['action' => 'index']);
			}

			$this->Flash->error(__('record edit not saved'));
		}

		$this->set(compact('country'));
	}
1268025
private function getCountryName($countryId)
    {
        return (!empty($countryId)) ?
            $this->_countryInformation->getCountryInfo($countryId)->getFullNameLocale() :
            $countryId;
    }
1313235
protected function canDeleteCountryState()
    {
        return isset($this->data_state['state_id'])
            && $this->state->canDelete($this->data_state['state_id'])
            && $this->access('state_delete');
    }
1001211
protected function submitEditCountryState()
    {
        if ($this->isPosted('delete')) {
            $this->deleteCountryState();
        } else if ($this->isPosted('save') && $this->validateEditCountryState()) {
            if (isset($this->data_state['state_id'])) {
                $this->updateCountryState();
            } else {
                $this->addCountryState();
            }
        }
    }
994394
public function canDelete($state_id)
    {
        $sql = 'SELECT address_id FROM address WHERE state_id=?';
        $result = $this->db->fetchColumn($sql, array($state_id));
        return empty($result);
    }
702924
public static function display($country, $callback, $subset = false)
    {
        // $country is the country to display states from
        // $callback is the anonymous function for formating the data
        // $subset should be an array of ok abbreviations, set to false for all states
        // Returns [true] on success, [false] if no states to display

        if (!is_callable($callback)) {
            throw new Exception('Callback function is not callable.');
        }
        if ($subset && !is_array($subset)) {
            throw new Exception('Subset must be false or an array of acceptable country abbreviations.');
        }

        if (class_exists('Countries') && !Countries::check($country)) {
            return false;
        }
        if (!isset(self::$list[$country])) {
            return false;
        }

        foreach (self::$list[$country] as $abbrv => $name) {
            if ($subset && !in_array($abbrv, $subset)) {
                continue;
            }

            echo $callback($abbrv, $name);
        }

        return true;
    }