- Issue created by @dbielke1986
- Status changed to Needs review
almost 2 years ago 9:33am 20 March 2023 - Status changed to Needs work
over 1 year ago 11:53am 6 April 2023 - ๐ฉ๐ชGermany dbielke1986
Unfortunately, this does not yet work as desired.
If you double-click on an existing embedded content to customize the content, the current plugin and its config are not pre-populated, but an initial dialog is called. - ๐ฉ๐ชGermany dbielke1986
It seems to be a better approach to use:
$plugin_config = !empty($plugin_config) ? Xss::filter($plugin_config) : '';
instead of code line 72
$plugin_config = Xss::filter($plugin_config);
- ๐บ๐ธUnited States cecrs
Fwiw, I was getting these issues due to a malformed array in my custom template. (Specifically the default_value for a text_format field, which has to be $this->configuration['']['value'], not $this->configuration['']. No patches were necessary.
Just as an fyi, to render a formatted field in the twig template, you will need to use this format:
{% set descriptionFormatted = {
'#type': 'processed_text',
'#text': description.value,
'#format': 'basic_html',
}
%}{{ descriptionFormatted }}
- ๐ฉ๐ชGermany dbielke1986
Hey @cecrs,
thank you for your input and the great information!
I already have the default value, as you described, but I still get an error if I do not change the code, or do you think this is because of the: NULL
This is the code for my fields in the buildConfigurationForm
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { // Create empty options array $options = array(); $langcodes = \Drupal::languageManager()->getLanguages(); // Inject into the options array foreach ($langcodes as $langcode => $key) { $options[$langcode] = $langcode; } $form['language'] = [ '#type' => 'select', '#title' => $this->t('Language'), '#default_value' => $this->configuration['language'], '#required' => TRUE, '#options' => $options, '#ajax' => [ 'callback' => [$this, 'updateText'], 'event' => 'change', 'wrapper' => 'text-field-wrapper', 'progress' => [ 'type' => 'throbber', 'message' => $this->t('Verifying entry...'), ], ], ]; $form['text'] = [ '#type' => 'text_format', '#format' => 'full_html', '#title' => $this->t('Text'), '#default_value' => (isset($this->configuration['text']['value']) ? $this->configuration['text']['value'] : NULL), '#prefix' => '<div id="text-field-wrapper">', '#suffix' => '</div>', ]; return $form; }
BR
Daniel - ๐บ๐ธUnited States cecrs
@Daniel
Possibly, I would suggest trying removing all except the minimal required config, clear cache see if it works. If it does, add things back one by one (clearing cache between each, natch) until it breaks. If not, the issue is somewhere else and my experience will be of no help... :P
Working example:
$form['text'] = array( '#type' => 'text_format', '#title' => $this->t('Text'), '#format' => 'basic_html', '#default_value' => $this->configuration['text']['value'], );
- ๐ฉ๐ชGermany dbielke1986
@cecrs:
I have realized that this error occurs even without my custom module. So, just activate the CKEditor5 embedded content module and click the button to insert a template.
Here comes then this message, but also the above PHP errors.
Anybody got this fixed? After applying the patch the deprecation error is fixed, but as mentioned in comment #5 now we are not able to edit the existing embed content. When we double click on the existing embedded content its opening a new dialog instead of opening the dialog with the existing values
- Status changed to Fixed
over 1 year ago 7:48am 9 July 2023 - ๐ช๐ธSpain nuez Madrid, Spain
Thank you, I've incorporated the suggestions in the latest dev release. Feel free to reopen if this is still is an issue
Automatically closed - issue fixed for 2 weeks with no activity.