Using $form_state->getValue() inside of blockForm() throws an exception. See issue #2798261: Using $form_state->getValue() in BlockBase's blockForm throws "subform and parent form must contain the #parents property" exception.

I'd write a patch, but I can't find any examples of how ajax rebuilds are supposed to work now that #2537732: PluginFormInterface must have access to the complete $form_state (introduce SubFormState for embedded forms) went in.

Comments

KarlShea created an issue. See original summary.

tedbow’s picture

Status: Active » Needs review
StatusFileSize
new1.18 KB

Here is a patch that fixes the error by calling but I would think it should be fixed in #2798261: Using $form_state->getValue() in BlockBase's blockForm throws "subform and parent form must contain the #parents property" exception.

I have not read up much on the SubFormState so likely this is the wrong way to solve it but it does work.

karlshea’s picture

According to #2798261-11: Using $form_state->getValue() in BlockBase's blockForm throws "subform and parent form must contain the #parents property" exception that's the way to do it—and it fixes it for me—but I still think someone that really knows how those SubFormState changes are supposed to work should weigh in.

mherchel’s picture

FYI, the patch in #2 fixed it for me.

eclipsegc’s picture

Status: Needs review » Postponed (maintainer needs more info)

So... this was annoying. I attempted to fix this in core, we'll see if my suggestion is worthwhile over on the other issue, otherwise we may adopt this patch shortly just as a stop-gap.

Eclipse

karlshea’s picture

StatusFileSize
new1.11 KB

As suggested in #2798261-32: Using $form_state->getValue() in BlockBase's blockForm throws "subform and parent form must contain the #parents property" exception, is there a reason that the form state input is needed at all here? It looks like changing #default_value to just use what's in $config works just fine.

karlshea’s picture

Status: Postponed (maintainer needs more info) » Needs review
japerry’s picture

damienmckenna’s picture

  • tim.plunkett committed 678c053 on 8.x-3.x authored by KarlShea
    Issue #2800951 by KarlShea, tedbow: EntityField block broken due to...
tim.plunkett’s picture

Status: Needs review » Fixed

Reviewed this in person with @EclipseGc, committed!
Thanks @KarlShea

Status: Fixed » Closed (fixed)

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