You are here

public function CountryStateWidget::ajaxFillState in Country, State and City Fields 8

Call the function that consume the webservice.

Parameters

array $form: A form that be modified.

\Drupal\Core\Form\FormStateInterface $form_state: The values of the form.

Return value

array The form modified

File

src/Plugin/Field/FieldWidget/CountryStateWidget.php, line 238

Class

CountryStateWidget
Plugin implementation of the 'country_state_widget' widget.

Namespace

Drupal\country_state_city\Plugin\Field\FieldWidget

Code

public function ajaxFillState(array $form, FormStateInterface $form_state) {
  $element = $form_state
    ->getTriggeringElement();
  $delta = $element['#delta'];
  $field_name = $this->fieldDefinition
    ->getName();
  $form = $form[$field_name];
  unset($form['widget'][$delta]['_weight']);
  return $form['widget'][$delta];
}