Problem/Motivation

ConfigSingleExportForm uses the Ajax API to dynamically update the form.

Proposed resolution

Refactor the form to use HTMX. The existing ajax callbacks can be adapted however their calling context changes and that necessitates the adaptation. If they are called during form building then they need to build correctly when input has not been processed at which point FormState::getValues returns empty.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#6 single-export-form-refactor.gif1.51 MBjoaopauloc.dev

Issue fork drupal-3545179

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

fathershawn created an issue. See original summary.

nod_’s picture

Title: [PP-1] Refactor ConfigSingleExportForm to use HTMX » Refactor ConfigSingleExportForm to use HTMX
Status: Postponed » Active

fathershawn’s picture

Status: Active » Needs review
fathershawn’s picture

All tests passing - only changes to the form. Existing test could remain in place because of HTMX detection added in #3535173: Support dynamic forms using HTMX

joaopauloc.dev’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.51 MB

I can confirm that the singles export item still working after the refactor.

Steps used to test:
New Drupal installation.
Checkout branch issue.
Navigated to /admin/config/development/configuration/single/export
Select the Configuration type.
Select the Configuration name.
The content of the settings loaded correct inside the textarea.

Attaching the evidence.
refactor testing.

nod_’s picture

Status: Reviewed & tested by the community » Needs work

very eager to get that in but a few things to fix first

fathershawn’s picture

Status: Needs work » Needs review

Feedback addressed and all tests passing.

nod_’s picture

Status: Needs review » Reviewed & tested by the community

I attached the push url to the form itself, since it's not about the field itself it's more about the whole form. And refactored a bit to make only one call to the pushUrlHeader.

I've spent days on this form trying to understand the form api, and an other version of this form is used in the Htmx tests so I'm confident we got everything working. it's also an improvment compared to before because we can use the back button of the browser now :)

fathershawn’s picture

nod_’s picture

seems like the last commit undid a bunch of things on the MR (including the fix to make sure we don't have "- Select -" in the push url).

reapplied the fixes and used the new method to get the trigger name.

fathershawn’s picture

Nice! Thank you @nod_

alexpott’s picture

Version: 11.x-dev » 11.3.x-dev
Status: Reviewed & tested by the community » Fixed

Backported to 11.3.x and this is not a disruptive change allowed during alpha.

Committed and pushed 9761c3f1048 to 11.x and 237e3e7b8e6 to 11.3.x. Thanks!

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.

  • alexpott committed 237e3e7b on 11.3.x
    Issue #3545179 by fathershawn, nod_, joaopauloc.dev: Refactor...

  • alexpott committed 9761c3f1 on 11.x
    Issue #3545179 by fathershawn, nod_, joaopauloc.dev: Refactor...
quietone’s picture

Publish CR

Status: Fixed » Closed (fixed)

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

gábor hojtsy’s picture

wim leers’s picture

Just wanted to say: I've noticed this change, and I very much appreciate it — a significant quality of life improvement! 👏🙏

(Catching up on months of core CRs, that's how I ended up finding and writing this!)

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

veverka42’s picture

Please reopen, i found an issue with the form. More details here https://www.drupal.org/project/chosen/issues/3568570#comment-16553454

fathershawn’s picture

I suspect this is about chosen integration with the form not expecting htmx. If you find a specific issue with the form, please open a new issue.

veverka42’s picture

Following your suggestion, I opened https://www.drupal.org/project/drupal/issues/3585442 with the problem description and proposed solution.

veverka42’s picture

The problem I reported was actually due to Webform Devel module, in which there is an hook which alters the ConfigSingleExportForm.

More details here https://www.drupal.org/project/drupal/issues/3585442#comment-16555761

veverka42’s picture

See https://www.drupal.org/project/drupal/issues/3586719 for an error occurring on a clean install (via composer create drupal/recommended-project)

veverka42’s picture

the problem reported in comment #26 occurs without additional modules installed

nicxvan’s picture