You are here

function ajax_dependent_dropdown in Brightcove Video Connect 7.7

Same name and namespace in other branches
  1. 7.6 brightcove.module \ajax_dependent_dropdown()

Triggered by a change in the 'Player' dropdown list. Updates the 'Child player' dropdown list, and the 'Create child player' link.

Parameters

$form: Parent $form.

$form_state: Parent $form_state

Return value

array AJAX commands array.

2 string references to 'ajax_dependent_dropdown'
_brightcove_field_playlist_widget_form in ./brightcove_field.playlist.inc
Helper function to return the playlist widget form.
_brightcove_field_video_widget_form in ./brightcove_field.video.inc
Helper function to return the video widget form.

File

./brightcove.module, line 1067
Brightcove module is an integration layer between any modules using Brightcove API. It makes all necessary checks for the API and makes settings available to the user.

Code

function ajax_dependent_dropdown($form, $form_state) {
  $delta = $form_state['triggering_element']['#parents'][2];
  $player_or_playlist = $form_state['triggering_element']['#parents'][0];
  if ($player_or_playlist == 'field_brightcove_playlist') {
    $wrapper_for_select_list = 'playlist-embed-replace-' . $delta;
    $wrapper_for_link = 'playlist-link-replace-' . $delta;
  }
  else {
    $wrapper_for_select_list = 'embed-replace-' . $delta;
    $wrapper_for_link = 'link-replace-' . $delta;
  }
  $commands = [];
  $commands[] = ajax_command_replace("#{$wrapper_for_select_list}", drupal_render($form[$player_or_playlist][LANGUAGE_NONE][$delta]['embed']));
  $commands[] = ajax_command_replace("#{$wrapper_for_link}", drupal_render($form[$player_or_playlist][LANGUAGE_NONE][$delta]['player_customization']['link_to_config']));
  return [
    '#type' => 'ajax',
    '#commands' => $commands,
  ];
}