Commit 8657314
committed
feature #32747 [Form] Add "is empty callback" to form config (fancyweb)
This PR was merged into the 5.1-dev branch.
Discussion
----------
[Form] Add "is empty callback" to form config
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #31572 for 4.4+
| License | MIT
| Doc PR | -
This PR introduces a new feature that allow to resolve a bug.
Currently, the `isEmpty()` behavior of the `Form` class is the same whatever its configuration. That prevents us to specify a different behavior by form type.
But I think that some form types should have dedicated empty values. For example, the `CheckboxType` model data either resolves to `true` (checked) or `false` (unchecked). But `false` is not an empty value in the `Form::isEmpty()` method, so a `CheckboxType` form can never be empty. `false` should not be in that list because for other form types, it's perfectly fine that it's not considered as an empty value.
The problem is better seen in #31572 with a `ChoiceType` that is never considered as empty (when no radio button is checked).
Being able to specify the "is empty" behavior by form type would also allow users to define their own logic in their custom form types + probably define it ourselves in all our form types in order to get rid of the default common behavior.
Commits
-------
7bfc27e [Form] Add "is empty callback" to form config16 files changed
+147Lines changed: 147 additions & 0 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- src/Symfony/Component/Form
- Extension/Core/Type
- Tests
- Extension/Core/Type
- Fixtures/Descriptor
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+8Lines changed: 8 additions & 0 deletions
- Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
16 | 16 | |
17 | 17 | |
18 | 18 | |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
19 | 27 | |
20 | 28 | |
21 | 29 | |
|
Collapse file
+6Lines changed: 6 additions & 0 deletions
- Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
16 | 16 | |
17 | 17 | |
18 | 18 | |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
19 | 25 | |
20 | 26 | |
21 | 27 | |
|
Collapse file
src/Symfony/Component/Form/ButtonBuilder.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ButtonBuilder.php+20Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
466 | 466 | |
467 | 467 | |
468 | 468 | |
| 469 | + |
| 470 | + |
| 471 | + |
| 472 | + |
| 473 | + |
| 474 | + |
| 475 | + |
| 476 | + |
| 477 | + |
| 478 | + |
469 | 479 | |
470 | 480 | |
471 | 481 | |
| ||
738 | 748 | |
739 | 749 | |
740 | 750 | |
| 751 | + |
| 752 | + |
| 753 | + |
| 754 | + |
| 755 | + |
| 756 | + |
| 757 | + |
| 758 | + |
| 759 | + |
| 760 | + |
741 | 761 | |
742 | 762 | |
743 | 763 | |
|
Collapse file
src/Symfony/Component/Form/CHANGELOG.md
Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/CHANGELOG.md+4Lines changed: 4 additions & 0 deletions
- Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
6 | 6 | |
7 | 7 | |
8 | 8 | |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
9 | 13 | |
10 | 14 | |
11 | 15 | |
|
Collapse file
src/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php+3Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
60 | 60 | |
61 | 61 | |
62 | 62 | |
| 63 | + |
| 64 | + |
| 65 | + |
63 | 66 | |
64 | 67 | |
65 | 68 | |
|
Collapse file
src/Symfony/Component/Form/Extension/Core/Type/FormType.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/FormType.php+11Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
15 | 15 | |
16 | 16 | |
17 | 17 | |
| 18 | + |
18 | 19 | |
19 | 20 | |
20 | 21 | |
| ||
58 | 59 | |
59 | 60 | |
60 | 61 | |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
61 | 70 | |
62 | 71 | |
63 | 72 | |
| ||
190 | 199 | |
191 | 200 | |
192 | 201 | |
| 202 | + |
193 | 203 | |
194 | 204 | |
195 | 205 | |
196 | 206 | |
197 | 207 | |
198 | 208 | |
199 | 209 | |
| 210 | + |
200 | 211 | |
201 | 212 | |
202 | 213 | |
|
Collapse file
src/Symfony/Component/Form/Form.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Form.php+12Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
726 | 726 | |
727 | 727 | |
728 | 728 | |
| 729 | + |
| 730 | + |
| 731 | + |
| 732 | + |
| 733 | + |
| 734 | + |
| 735 | + |
| 736 | + |
| 737 | + |
| 738 | + |
| 739 | + |
| 740 | + |
729 | 741 | |
730 | 742 | |
731 | 743 | |
|
Collapse file
src/Symfony/Component/Form/FormConfigBuilder.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/FormConfigBuilder.php+19Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
102 | 102 | |
103 | 103 | |
104 | 104 | |
| 105 | + |
105 | 106 | |
106 | 107 | |
107 | 108 | |
| ||
461 | 462 | |
462 | 463 | |
463 | 464 | |
| 465 | + |
| 466 | + |
| 467 | + |
| 468 | + |
| 469 | + |
| 470 | + |
| 471 | + |
| 472 | + |
464 | 473 | |
465 | 474 | |
466 | 475 | |
| ||
761 | 770 | |
762 | 771 | |
763 | 772 | |
| 773 | + |
| 774 | + |
| 775 | + |
| 776 | + |
| 777 | + |
| 778 | + |
| 779 | + |
| 780 | + |
| 781 | + |
| 782 | + |
764 | 783 | |
765 | 784 | |
766 | 785 | |
|
Collapse file
src/Symfony/Component/Form/FormConfigBuilderInterface.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/FormConfigBuilderInterface.php+2Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
16 | 16 | |
17 | 17 | |
18 | 18 | |
| 19 | + |
| 20 | + |
19 | 21 | |
20 | 22 | |
21 | 23 | |
|
Collapse file
src/Symfony/Component/Form/FormConfigInterface.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/FormConfigInterface.php+2Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
18 | 18 | |
19 | 19 | |
20 | 20 | |
| 21 | + |
| 22 | + |
21 | 23 | |
22 | 24 | |
23 | 25 | |
|
0 commit comments