Commit 90a2eb1
committed
bug #2491 [LiveComponent] Fix
This PR was squashed before being merged into the 2.x branch.
Discussion
----------
[LiveComponent] Fix `ComponentWithFormTrait::extractFormValues()` with edge cases
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Issues | Fix #2487
| License | MIT
#2403 fixed an old bug to simulate browser behaviour when a select field has no option selected, no placeholder, and is required (it then uses the first option)
#2425 and #2426 fixed the way we handled empty strings as placeholders
In #2487 `@maciazek` explained us how a custom type with a "choices" option became unusable since the last changes.
Also.. while I was reading all this I realized we returned wrong values here when "option groups" were used.. leading to other problems.
I updated the code of `extractFormValues()` method to:
* check if most of the caracteristic keys added in `ChoiceType::buildView` were defined in the `$view->vars`, to ensure we are dealing with a `<select>` field built by a `ChoiceType`
* fetch recursively the value of the first displayed option (even with groups)
Commits
-------
b7f1ba4 [LiveComponent] Fix `ComponentWithFormTrait::extractFormValues()` with edge casesComponentWithFormTrait::extractFormValues() with edge cases (smnandre)File tree
4 files changed
+39
-13
lines changed- src/LiveComponent
- src
- tests
- Fixtures/Form
- Functional/Form
- Unit/Form
4 files changed
+39
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
255 | 256 | | |
256 | 257 | | |
257 | 258 | | |
| 259 | + | |
258 | 260 | | |
259 | | - | |
260 | 261 | | |
261 | 262 | | |
262 | 263 | | |
263 | 264 | | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
272 | 282 | | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
277 | 292 | | |
278 | 293 | | |
279 | 294 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
68 | 77 | | |
69 | 78 | | |
70 | 79 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| 184 | + | |
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
0 commit comments