[4.x]: Form serialization does not include values set in web components
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 705
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 134
Description
What happened?
Description
I'm updating one of our plugins, moving away from pre-processed JS to modular web components. One issue I'm having is getting the control panel to notice that input data in the component has changed.
Web components can set data on a form using setFormValues, but this isn't picked up by what I assume is jQuery's form serialization.
A fix would be to pass the form directly to a FormData constructor and let the browser serialize the form.
Steps to reproduce
- Create a field that includes a web component that uses
setFormValues. - Make a change to the field.
Expected behavior
Craft should serialize the form in a way that detects the change.
Actual behavior
Craft ignores the field.
Craft CMS version
4.4.8
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the control-panel form serialization used when a field changes; the issue does not name a file or test. Reproduce the case with a form-associated web component using setFormValue, then verify that the serialized data includes the component's value and that the control panel detects the change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, php
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100