🇵🇰Pakistan alinouman
Working for some pages and not working for other.
🐛 | Entity Browser | Entity Browser used in a entity referenced field of a layout builder custom block is not working
🇵🇰Pakistan alinouman
#31 works good for me. Thanks david-b for your help.
🇵🇰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.