Problem/Motivation

The Component plugin in embedded_content_sdc has two bugs
that prevent SDC components from working when embedded via CKEditor:

  1. build() returns an empty array — When a user embeds
    an SDC component in CKEditor and saves the node, nothing is rendered on the frontend.
    The build() 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.
  2. buildConfigurationForm() crashes with a TypeError
    The method calls buildForm() 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 the schema-forms library 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

  1. Enable embedded_content_sdc and configure an Embedded Content button
    for a CKEditor text format.
  2. Create an SDC component in a custom module (e.g., a component with string
    props).
  3. Edit a node, click the Embedded Content button in CKEditor, and select your SDC
    component from the dropdown.
  4. Observed: An error message appears in the dialog, and if the
    form does render, saving the node produces no visible output for the component.
  5. 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 #props and
    #slots from $this->configuration.
  • buildConfigurationForm(): Replaces the broken
    double buildForm() call with a single call to
    cl_editorial_component_mappings_form(), passing
    $this->configuration instead of $form_state->getValues().
    This also removes the now-unused ComponentInputToForm import.

Remaining tasks

  • Review and merge MR !4.

User interface changes

None.

API changes

None.

Data model changes

None.

Command icon 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

johnny5th created an issue. See original summary.

liam morland made their first commit to this issue’s fork.

liam morland’s picture

Status: Active » Needs review
liam morland’s picture

Version: » 1.0.x-dev
Status: Needs review » Needs work
Issue tags: +Needs reroll

mrinalini9 made their first commit to this issue’s fork.

liam morland’s picture

Coding standards are not passing on the merge request.

Others, please test this.

liam morland’s picture

I 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.

arnalyse’s picture

Thanks for all involved, this patch helped us greatly.

Can I somehow help to finish/merge/close this issue?

liam morland’s picture

Issue tags: +Needs reroll

See #8.

das.gautam’s picture

Issue summary: View changes
das.gautam’s picture

Status: Needs work » Needs review

@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.

graber’s picture

Status: Needs review » Needs work

1 nit, commented on the MR.

liam morland’s picture

Status: Needs work » Needs review
Issue tags: -Needs issue summary update, -Needs reroll

  • liam morland committed c7805358 on 1.0.x
    fix: #3441939 Remove duplicated call to ::buildForm() in Component::...
liam morland’s picture

Status: Needs review » Fixed

Thanks very much!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.