Problem/Motivation
I have a custom block that needs to reference the form structure in its submit handler. However, when that block is added to layout builder, it can't find any of the fields it expects in its form.
I determined this is because ConfigureBlockFormBase.php passes the entire form to the submit handler instead of just the subform.
Steps to reproduce
N/A
Proposed resolution
I'm actually a bit puzzled what the "correct" way to invoke the submission handler subforms--I see examples of both in core:
1. The submit handler only passes the subform
* Drupal\field_layout\Form\FieldLayoutEntityDisplayFormTrait
* Drupal\image\Form\ImageEffectFormBase
* Drupal\layout_builder\Form\ConfigureSectionForm
* (and more)
2. The submit handler passes the whole form
* Drupal\block\BlockForm
Based on what appears to be the intention, I think the attached patch is correct.
Remaining tasks
N/A
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3227026-1.patch | 948 bytes | mediabounds |
Comments
Comment #2
mediabounds commentedComment #3
mediabounds commentedAlso updating BlockForm since as I review other examples in core and contrib modules, I think the intention is to only pass the subform.
(Not sure if the component should change here)
Comment #6
mediabounds commentedThe failing tests indicate this is the intended behavior…which seemed bizarre to me. So after some searching, I found that this is a known issue with Block which has essentially been replicated in Layout Builder: #2948549: Sub form not passed to BlockPlugin's submit callback