Problem/Motivation
The Component plugin in embedded_content_sdc has two bugs
that prevent SDC components from working when embedded via CKEditor:
build()returns an empty array — When a user embeds
an SDC component in CKEditor and saves the node, nothing is rendered on the frontend.
Thebuild()method returns[]instead of a render array that
uses Drupal's#type => 'component'element to render the SDC component
with its saved props and slots.buildConfigurationForm()crashes with a TypeError —
The method callsbuildForm()twice: once via
cl_editorial_component_mappings_form()and again directly via
ComponentInputToForm::buildForm(). The second call passes
$form_state->getValues()as the current input, which is an empty array on
initial form load. This causes theschema-formslibrary to throw:
"Adaptor SchemaForms\Drupal\FormGeneratorDrupal received invalid input data:
[]". The error appears in the CKEditor dialog as: "The subform and parent form
must contain the #parents property".
Steps to reproduce
- Enable
embedded_content_sdcand configure an Embedded Content button
for a CKEditor text format. - Create an SDC component in a custom module (e.g., a component with string
props). - Edit a node, click the Embedded Content button in CKEditor, and select your SDC
component from the dropdown. - Observed: An error message appears in the dialog, and if the
form does render, saving the node produces no visible output for the component. - Expected: The component's configuration form renders in the
dialog, and the component renders on the frontend after saving.
Proposed resolution
MR !4 fixes both issues in Component.php:
build(): Renders the SDC component using Drupal's
#type => 'component'render element, passing#propsand
#slotsfrom$this->configuration.buildConfigurationForm(): Replaces the broken
doublebuildForm()call with a single call to
cl_editorial_component_mappings_form(), passing
$this->configurationinstead of$form_state->getValues().
This also removes the now-unusedComponentInputToFormimport.
Remaining tasks
- Review and merge MR !4.
User interface changes
None.
API changes
None.
Data model changes
None.
Issue fork embedded_content_sdc-3441939
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
liam morlandComment #5
liam morlandComment #7
liam morlandCoding standards are not passing on the merge request.
Others, please test this.
Comment #8
liam morlandI have fixed the coding standards issue. Please update the issue summary using the default issue template and clearly explain the problem this is trying to solve. I expect to make a full release soon.
Comment #9
arnalyse commentedThanks for all involved, this patch helped us greatly.
Can I somehow help to finish/merge/close this issue?
Comment #10
liam morlandSee #8.
Comment #11
das.gautam commentedComment #12
das.gautam commented@liam morland
I've updated the issue summary using the default issue template as you requested in #8, clearly explaining the two problems this MR addresses. I've also rebased the MR branch onto the latest 1.0.x and resolved the merge conflict.
When you have a moment, could you please review MR !4? Happy to make any further changes if needed.
Comment #13
graber commented1 nit, commented on the MR.
Comment #14
liam morlandComment #17
liam morlandThanks very much!