You are here

public function AddressPaneBase::ajaxRender in Ubercart 8.4

Ajax callback to re-render the full address element.

File

uc_cart/src/Plugin/Ubercart/CheckoutPane/AddressPaneBase.php, line 182

Class

AddressPaneBase
Provides a generic address pane that can be extended as required.

Namespace

Drupal\uc_cart\Plugin\Ubercart\CheckoutPane

Code

public function ajaxRender(array $form, FormStateInterface $form_state) {
  $element =& $form;
  $triggering_element = $form_state
    ->getTriggeringElement();
  foreach (array_slice($triggering_element['#array_parents'], 0, -1) as $field) {
    $element =& $element[$field];
  }
  $response = new AjaxResponse();
  $id = $this->pluginDefinition['id'] . '-address-pane';
  $response
    ->addCommand(new ReplaceCommand('#' . $id, trim(drupal_render($element['address']))));
  $status_messages = [
    '#type' => 'status_messages',
  ];
  $response
    ->addCommand(new PrependCommand('#' . $id, drupal_render($status_messages)));
  return $response;
}