public static function MediaForm::onChange in Lightning Media 8
Same name and namespace in other branches
- 8.4 src/Form/MediaForm.php \Drupal\lightning_media\Form\MediaForm::onChange()
- 8.2 src/Form/MediaForm.php \Drupal\lightning_media\Form\MediaForm::onChange()
- 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\FormCode
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');
}