Overview
Quoting #3454094: Milestone 0.1.0: Experience Builder Demo:
- As a content creator, I want to edit meta fields directly within the page builder interface. For example, the menu links and URL alias should be editable on the same page as the page builder.
(Saving these is out of scope — because it is out of scope for #3450586: [META] Back-end Kanban issue tracker too.)
Proposed resolution
- Route definition:
experience_builder.api.entity_form: path: '/xb/api/entity-form/{entity_type}/{entity}/{entity_form_mode}' defaults: _form: '\Drupal\experience_builder\Form\EntityForm' _title: 'Entity Form' requirements: _permission: 'access administration pages' options: parameters: entity: type: entity:{entity_type} Retrieve$form['meta'](seeNodeForm) — more scalable solution to follow in #3463991: [RESEARCH] How to identify all meta fields for an arbitrary content entity?Per @lauriii in #6: use the route's "form mode" parameter, to load the appropriate form. The intent: start with the default node edit form, but allow defining a separate form mode +
EntityFormDisplayfor a more tailored UX. @lauriii expressed explicitly the desire for this parametrization, to allow not needing to redo this in the future.(Stepping through how
/node/1/editworks, it's\Drupal\Core\Entity\Enhancer\EntityRouteEnhancer+\Drupal\Core\Entity\Entity\EntityFormDisplay::collectRenderDisplay()that do the crucial pieces. But note how\Drupal\Core\Entity\Enhancer\EntityRouteEnhancer::enhanceEntityView()does have an explicit mention of$defaults['view_mode'] = $view_mode;, but\Drupal\Core\Entity\Enhancer\EntityRouteEnhancer::enhanceEntityForm()has no equivalent!)- Explicit high-level test coverage for verifying this route returns form markup (
BrowserTestBase,Cypress E2Etest is impossible in this issue). - Don't worry about CSS/JS assets for now: getting the form to load at all is the goal (there are other issues in progress that improve the asset loading parts).
- The expected request body should be documented in
/openapi.yml.
User interface changes
None — we'll need a front-end sibling issue to actually use this. This is about allowing that front-end work to happen independently, about pre-emptively unblocking that.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | Screenshot from 2024-08-20 18-27-42.png | 93.85 KB | longwave |
Issue fork experience_builder-3463988
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 #2
wim leersComment #3
wim leersComment #4
wim leersAsked @lauriii for clarification at #3459234-10: [needs design] [research] Allow directly creating/editing entity title and meta fields.
Comment #6
wim leersAfter discussing this in-depth with @lauriii, he is requesting this pivot:
should both be covered by this; with the widgets for all of the entity fields (except for the XB field) appearing in the right sidebar, and hence in a single form. IOW: everything in the
defaultform mode/display.But the implementation should allow specifying a form mode, to allow in the future requesting only the meta fields (TBD how to identify these: #3463991: [RESEARCH] How to identify all meta fields for an arbitrary content entity?), or only the "structured data" fields.
Comment #7
larowlanShouldn't the url also include entity type and id?
Comment #9
wim leers— @longwave at #3463991-7: [RESEARCH] How to identify all meta fields for an arbitrary content entity?.
Let's use that heuristic in this initial implementation 👍
Comment #10
wim leersComment #11
wim leersComment #13
longwaveThe MR so far adds the route and a controller that returns the form HTML wrapped in JSON.
I tried to start writing a test but I get a 404 from /xb/api/entity-form/node/1 and I'm not sure why.
This will also need better access checking added to the route, but this is enough to get started.
Comment #15
tedbowgot the test passing locally but looks I have update something for OpenApi spec to get the test to pass. Haven't had time to figure this yet
Comment #16
tedbowI think this is ready
Comment #17
tedbowComment #18
wim leersA few questions about things that are unclear to me, but mostly requests for documenting the tricky things that you and @longwave identified/encountered :)
Comment #19
tedbowComment #20
wim leersComment #21
wim leersCI failed only due to #3469865: Unbreak CI: #3458422 in Drupal 10.4 changed a method signature XB is overriding.
Comment #23
wim leers