EditorDialogSave example



    if ($form_state->getErrors()) {
      unset($form['#prefix']$form['#suffix']);
      $form['status_messages'] = [
        '#type' => 'status_messages',
        '#weight' => -10,
      ];
      $response->addCommand(new HtmlCommand('#editor-image-dialog-form', $form));
    }
    else {
      $response->addCommand(new EditorDialogSave($form_state->getValues()));
      $response->addCommand(new CloseModalDialogCommand());
    }

    return $response;
  }

}

  public function getSelectionResponse(MediaLibraryState $state, array $selected_ids) {
    $selected_media = $this->mediaStorage->load(reset($selected_ids));

    $response = new AjaxResponse();
    $values = [
      'attributes' => [
        'data-entity-type' => 'media',
        'data-entity-uuid' => $selected_media->uuid(),
      ],
    ];
    $response->addCommand(new EditorDialogSave($values));

    return $response;
  }

}
$response = new AjaxResponse();

    if ($form_state->getErrors()) {
      unset($form['#prefix']$form['#suffix']);
      $form['status_messages'] = [
        '#type' => 'status_messages',
        '#weight' => -10,
      ];
      $response->addCommand(new HtmlCommand('#editor-link-dialog-form', $form));
    }
    else {
      $response->addCommand(new EditorDialogSave($form_state->getValues()));
      $response->addCommand(new CloseModalDialogCommand());
    }

    return $response;
  }

}
'#type' => 'status_messages',
        '#weight' => -10,
      ];
      $response->addCommand(new HtmlCommand('#editor-media-dialog-form', $form));
    }
    else {
      // Only send back the relevant values.       $values = [
        'hasCaption' => $form_state->getValue('hasCaption'),
        'attributes' => $form_state->getValue('attributes'),
      ];
      $response->addCommand(new EditorDialogSave($values));
      $response->addCommand(new CloseModalDialogCommand());
    }

    return $response;
  }

  /** * Gets the default value for the view mode form element. * * @param array $view_mode_options * The array of options for the view mode form element. * @param \Drupal\filter\Plugin\FilterInterface $media_embed_filter * The media embed filter. * @param string $media_element_view_mode_attribute * The data-view-mode attribute on the <drupal-media> element. * * @return string|null * The default value for the view mode form element. */
Home | Imprint | This part of the site doesn't use cookies.