Problem/Motivation

Following #3549348: Fatal: Default value for props, on load

If the value of a required prop is removed from ContextualFormPanel, no control is done, the prop storage is updated and we have a fatal error (probably Twig\Error\RuntimeError: An exception has been thrown during the rendering of a template The property xxx is required.)

In UI Patterns 2, we rely on Form API blocking ComponentForm submission to avoid this unfortunate situation.

Proposed resolution

Must be done in 2 steps:

  • Client side: Don't send the request to display_builder.api_update maybe by adding hx-validate https://htmx.org/attributes/hx-validate/ to onInstanceFormChange and onInstanceUpdateButtonClick HTMX events.
  • Server-side:: in ApiController::update(), don't update the instance (InstanceInterface->setSource()) if the form is not validating
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

pdureau created an issue. See original summary.

pdureau’s picture

For information, the related issue on SDC Devel: #3551361: Raise an error when a required prop has no default value

just_like_good_vibes’s picture

Assigned: Unassigned » just_like_good_vibes

pdureau’s picture

Status: Active » Needs work

Needs work. Don't use FormAjaxException but ApiController::responseMessageError() because we already handle this kind of situations.

just_like_good_vibes’s picture

Assigned: just_like_good_vibes » pdureau
Status: Needs work » Needs review
pdureau’s picture

Assigned: pdureau » mogtofu33
Status: Needs review » Reviewed & tested by the community

Functional review: OK for me.

What about the technical implementation? Is it OK too?

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

mogtofu33’s picture

Status: Reviewed & tested by the community » Needs work

I am not sure about the try/catch instead of responseMessageError, as we are hiding the error in the request.

mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
pdureau’s picture

Assigned: Unassigned » just_like_good_vibes
just_like_good_vibes’s picture

Assigned: just_like_good_vibes » mogtofu33
Status: Needs work » Needs review

i did some little changes and added some comments :)

mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Needs review » Fixed

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.