Skip to content

Commit d33c00b

Browse files
committed
feature #51076 [Form] Remove deprecations in form events (HeahDude)
This PR was merged into the 7.0 branch. Discussion ---------- [Form] Remove deprecations in form events | Q | A | ------------- | --- | Branch? | 7.0 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | ~ | License | MIT | Doc PR | ~ Commits ------- 87c91fb [Form] Remove deprecations in form events
2 parents 769c314 + 87c91fb commit d33c00b

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

UPGRADE-7.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ Form
9999
`model_timezone` option in `DateType`, `DateTimeType`, and `TimeType`
100100
* Make the "widget" option of date/time form types default to "single_text"
101101
* Require explicit argument when calling `Button/Form::setParent()`, `ButtonBuilder/FormConfigBuilder::setDataMapper()`, `TransformationFailedException::setInvalidMessage()`
102+
* `PostSetDataEvent::setData()` throws an exception, use `PreSetDataEvent::setData()` instead
103+
* `PostSubmitEvent::setData()` throws an exception, use `PreSubmitDataEvent::setData()` or `SubmitDataEvent::setData()` instead
102104

103105
FrameworkBundle
104106
---------------

src/Symfony/Component/Form/Event/PostSetDataEvent.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@
2222
*/
2323
final class PostSetDataEvent extends FormEvent
2424
{
25-
/**
26-
* @deprecated since Symfony 6.4, it will throw an exception in 7.0.
27-
*/
2825
public function setData(mixed $data): void
2926
{
30-
trigger_deprecation('symfony/form', '6.4', 'Calling "%s()" will throw an exception as of 7.0, listen to "form.pre_set_data" instead.', __METHOD__);
31-
// throw new BadMethodCallException('Form data cannot be changed during "form.post_set_data", you should use "form.pre_set_data" instead.');
27+
throw new BadMethodCallException('Form data cannot be changed during "form.post_set_data", you should use "form.pre_set_data" instead.');
3228
}
3329
}

src/Symfony/Component/Form/Event/PostSubmitEvent.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Event;
1313

14+
use Symfony\Component\Form\Exception\BadMethodCallException;
1415
use Symfony\Component\Form\FormEvent;
1516

1617
/**
@@ -21,12 +22,8 @@
2122
*/
2223
final class PostSubmitEvent extends FormEvent
2324
{
24-
/**
25-
* @deprecated since Symfony 6.4, it will throw an exception in 7.0.
26-
*/
2725
public function setData(mixed $data): void
2826
{
29-
trigger_deprecation('symfony/form', '6.4', 'Calling "%s()" will throw an exception as of 7.0, listen to "form.pre_submit" or "form.submit" instead.', __METHOD__);
30-
// throw new BadMethodCallException('Form data cannot be changed during "form.post_submit", you should use "form.pre_submit" or "form.submit" instead.');
27+
throw new BadMethodCallException('Form data cannot be changed during "form.post_submit", you should use "form.pre_submit" or "form.submit" instead.');
3128
}
3229
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy