function _gutenberg_media_form_alter in Gutenberg 8.2
Same name and namespace in other branches
- 8 gutenberg.module \_gutenberg_media_form_alter()
Alter media form.
1 call to _gutenberg_media_form_alter()
- gutenberg_form_alter in ./
gutenberg.module - Implements hook_form_alter().
File
- ./
gutenberg.module, line 602 - Provides integration with the Gutenberg editor.
Code
function _gutenberg_media_form_alter(array &$form, FormStateInterface $form_state, string $form_id) {
$is_gutenberg = !is_null(\Drupal::request()->query
->get('gutenberg'));
if (!$is_gutenberg) {
return;
}
$form['actions']['delete']['#access'] = FALSE;
unset($form['actions']['delete']);
$form['#after_build'][] = 'gutenberg_form_media_edit_form_after_build';
$form['actions']['submit']['#submit'][] = 'gutenberg_form_media_edit_form_submit';
$form['actions']['submit']['#ajax'] = [
'callback' => 'gutenberg_form_media_edit_form_submit',
'event' => 'click',
];
$form['actions']['cancel'] = [
'#weight' => 99,
'#type' => 'button',
'#value' => t('Cancel'),
'#ajax' => [
'callback' => 'gutenberg_form_media_edit_form_cancel',
'event' => 'click',
],
];
$form['#submit'][] = 'gutenberg_form_media_edit_form_submit';
}