You are here

public static function MediaForm::onChange in Lightning Media 8

Same name and namespace in other branches
  1. 8.4 src/Form/MediaForm.php \Drupal\lightning_media\Form\MediaForm::onChange()
  2. 8.2 src/Form/MediaForm.php \Drupal\lightning_media\Form\MediaForm::onChange()
  3. 8.3 src/Form/MediaForm.php \Drupal\lightning_media\Form\MediaForm::onChange()

AJAX callback. Updates and renders the source field.

Parameters

array $form: The complete form.

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

Return value

array The renderable source field.

File

src/Form/MediaForm.php, line 95

Class

MediaForm
Adds dynamic preview support to the media entity form.

Namespace

Drupal\lightning_media\Form

Code

public static function onChange(array &$form, FormStateInterface $form_state) {

  /** @var static $handler */
  $handler = $form_state
    ->getFormObject();
  $entity = $handler
    ->getEntity();
  $handler
    ->copyFormValuesToEntity($entity, $form, $form_state);
  return Helper::getSourceField($entity)
    ->view('default');
}