You are here

public static function BrightcovePlaylistForm::apiClientUpdateForm in Brightcove Video Connect 8.2

Same name and namespace in other branches
  1. 8 src/Form/BrightcovePlaylistForm.php \Drupal\brightcove\Form\BrightcovePlaylistForm::apiClientUpdateForm()
  2. 3.x src/Form/BrightcovePlaylistForm.php \Drupal\brightcove\Form\BrightcovePlaylistForm::apiClientUpdateForm()

Ajax callback to update the player options list.

Parameters

array $form: An associative array containing the structure of the form.

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

Return value

\Drupal\Core\Ajax\AjaxResponse Ajax command response.

Overrides BrightcoveVideoPlaylistForm::apiClientUpdateForm

File

src/Form/BrightcovePlaylistForm.php, line 128

Class

BrightcovePlaylistForm
Form controller for Brightcove Playlist edit forms.

Namespace

Drupal\brightcove\Form

Code

public static function apiClientUpdateForm(array $form, FormStateInterface $form_state) {
  $response = parent::apiClientUpdateForm($form, $form_state);

  // Remove videos from the field if the api client is changed.
  foreach (Element::children($form['videos']['widget']) as $delta) {
    if (is_numeric($delta)) {
      $form['videos']['widget'][$delta]['target_id']['#value'] = '';
    }
  }

  // Update videos fields.
  $response
    ->addCommand(new ReplaceCommand('#' . $form['videos']['#ajax_id'], $form['videos']));
  return $response;
}