Account created on 19 July 2011, almost 13 years ago
#

Recent comments

πŸ‡΅πŸ‡°Pakistan alinouman

I fixed it in a different way

/**
 * Implements hook_form_alter().
 */
function st_ckeditor_form_alter(&$form, FormStateInterface $formState, $formId) {
  $step = $formState->get('step');
  if ($formId === 'entity_embed_dialog' && $step === 'embed') {
    // Retrieve the saved 'entity_class' value from the embed attributes.
    $entityClass = $formState->get('entity_element')["data-entity-class"] ?? 'none';
    // Add a new field to the form for class assignment.
    $form['entity_class'] = [
      '#type' => 'radios',
      '#title' => t('Entity Class'),
      '#description' => t('Choose a class to be added to the entity.'),
      '#default_value' => $entityClass,
      '#options' => [
        'none' => t('None'),
        'wysiwyg-padding-right' => t('Padding Right'),
        'wysiwyg-padding-left' => t('Padding Left'),
      ],
    ];
    // Change the form submit handler.
    $form['#submit'][] = 'st_ckeditor_media_entity_embed_submit';
  }
}

/**
 * Custom submit handler for the media_entity_embed_dialog form.
 */
function st_ckeditor_media_entity_embed_submit($form, FormStateInterface $formState) {
  // Get the value of the 'entity_class' field.
  $entityClass = $formState->getValue('entity_class');
  // Store the entity class in the embed button attributes.
  $formState->setValue(['attributes', 'data-entity-class'], $entityClass);
}
πŸ‡΅πŸ‡°Pakistan alinouman

I'm also looking a solution for it.

Production build 0.69.0 2024