Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Form] Changed Form::getErrors() to return an iterator and added two optional parameters $deep and $flatten#9918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 2 commits intosymfony:masterfromwebmozart:issue9099
Mar 11, 2014

Conversation

webmozart
Copy link
Contributor

QA
Bug fix?no
New feature?yes
BC breaks?yes
Deprecations?yes
Tests pass?yes
Fixed tickets#7205
LicenseMIT
Doc PR-

See the changes in the UPGRADE files for more information.

* Creates a new iterator.
*
* @param array $errors The iterated errors
* @param FormInterface $form The for the errors belong to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Typo: for

@webmozart
Copy link
ContributorAuthor

I rebased this PR and changed the default value of$flatten to true.

*/
public function __construct(array &$errors, FormInterface $form, $deep = false, $flatten = true)
{
$this->errors = &$errors;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Shouldn't this be$this->elements rather than$this->errors ? Or shouldn't you at least declare the$errors property ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

And I don't really see the point of having a duplicate between$this->elements and$this->errors, or to have a reference from the$errors array

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@webmozartthis->errors is not declared

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks. See#10418

@ahilles107
Copy link

👍

@alexsegura
Copy link
Contributor

👍

This is a must have, currentlyForm::getErrors is just useless

@fabpot
Copy link
Member

I don't like breaking BC at this point. What about adding a new method instead?

@Djeg
Copy link

👍

Totaly agree ! I have to do that recursively each time i need it, a must have.

@fabpot
Copy link
Member

@webmozart What are we doing with this PR? I still think that breaking BC here is not a good idea. I know that FormatInterface is not marked with the@api tag but still...

@Seb33300
Copy link
Contributor

I can understand you think that breaking BC here is not a good idea, but sometimes, i think it is a better way than keeping useless functionnalities. Especially when the new version looks similar to what the functionality should have been from the beginning.

@wouterj
Copy link
Member

@fabpot the only thing that is breaking BC is if you implemented theFormInterface in a custom Form class or if you override that method. I don't believe many people did one of those things...

@fabpot
Copy link
Member

@wouterj The returned value also changed... That's the biggest BC break for me.

@webmozart
Copy link
ContributorAuthor

We basically have two choices:

(1) We leave this PR as is. This means:

  • People who implementFormInterface must add the new optional arguments togetErrors().
  • People who usegetErrors() need to useiterator_to_array()if they pass the errors to a function that only accepts arrays (array type hint,array_*())

Before:

$errors =$form->getErrors();echo$errors[0];echocount($errors);$mappedErrors =array_map($callback,$errors);// Print all errorsecho$form->getErrorsAsString();

After:

$errors =$form->getErrors();echo$errors[0];echocount($errors);$mappedErrors =array_map($callback,iterator_to_array($errors));// Print all errorsecho$form->getErrors($deep =true);// Count all errorsechocount($form->getErrors($deep =true));// Get all errors as recursive iterator$errors =$form->getErrors($deep =true,$flatten =false);

(2) We leavegetErrors() unchanged and add the new functionality to a new method instead. Name proposal:getErrorIterator(). This means:

  • People who implementFormInterface must add the new methodgetErrorIterator().
$errors =$form->getErrors();echo$errors[0];echocount($errors);$mappedErrors =array_map($callback,$errors);// Print all errorsecho$form->getErrorIterator($deep =true);// Count all errorsechocount($form->getErrorIterator($deep =true));// Get all errors as recursive iterator$errors =$form->getErrorIterator($deep =true,$flatten =false);

I created a poll which lets you select one of these answers:http://poll.fm/4obja. I will close the poll in a couple of days.

@hhamon
Copy link
Contributor

For BC I think it's safer to add a new method and deprecate the previous one (to be removed in 3.0).

Instead of modifying the currentFormInterface, why not adding a newFormErrorInterface (or something similar) so that aForm instance implements bothFormInterface andFormErrorInterface? Those two interfaces may be merged in branch 3.0.

@wouterj
Copy link
Member

Instead of modifying the current FormInterface , why not adding a new FormErrorInterface (or something similar) so that a Form instance implements both FormInterface and FormErrorInterface ?

That's a huge code smell imo (sadly it's one of the result of the 100% BC promise). How am I going to typehint a form class where I want to use both the methods in FormInterface and the new FormErrorInterface? That's impossible...

@webmozart
Copy link
ContributorAuthor

I agree with@wouterj here. Also,FormInterface is not marked as API, so itmay be changed for a good reason.

@webmozart
Copy link
ContributorAuthor

Since the poll didn't receive any votes anymore for a few days, I closed it now. The results can be seen here:https://polldaddy.com/poll/7853158/?view=results

  • 30 people (51%) voted for keeping the PR as it is: add additional parameters togetErrors() and change the return type to an iterator
  • 29 people (49%) voted for adding an extra methodgetErrorIterator()

The poll shows that the community is just as split about this issue as we are. However, we have a majority, so I propose to merge the PR as it is based on the decision made by the voters.

fabpot added a commit that referenced this pull requestMar 11, 2014
…and added two optional parameters $deep and $flatten (webmozart)This PR was merged into the 2.5-dev branch.Discussion----------[Form] Changed Form::getErrors() to return an iterator and added two optional parameters $deep and $flatten| Q             | A| ------------- | ---| Bug fix?      | no| New feature?  | yes| BC breaks?    | yes| Deprecations? | yes| Tests pass?   | yes| Fixed tickets |#7205| License       | MIT| Doc PR        | -See the changes in the UPGRADE files for more information.Commits-------6b3fbb5 [Form] Changed the default value of $flatten in Form::getErrors() to truea9268c4 [Form] Changed Form::getErrors() to return an iterator and added two optional parameters $deep and $flatten
@fabpotfabpot merged commit6b3fbb5 intosymfony:masterMar 11, 2014
@webmozartwebmozart deleted the issue9099 branchMarch 11, 2014 11:45
@Strate
Copy link
Contributor

Method with several bool parameters looks ugly in code:

$errors =$form->getErrors(true,false);

So, in future it can easily evolve to:

$errors =$form->getErrors(true,false,false,false,true,true,false);

Very bad for reading and understandingwithout looking to method's definition.

If link to poll had been in previous "Week of symfony" blog entry, I would had voted for new method.

@wouterj
Copy link
Member

@Strate the new method would have exact the same signature. The question was whether it was a problem that the method returned a Traversable instead of an array and it had a new extra parameter.

@webmozart
Copy link
ContributorAuthor

@Strate Can you make a suggestion how to improve the API?

@Strate
Copy link
Contributor

@webmozart For me it would be great having setters for options in iterator class. See examples:
Before:

$form->getErrors($deep=false,$flatten =true);

After:

$form->getErrors()->setDeep(false)->setFlatten(true);

This example more readable for me.

P.S.
Every set method should return NEW instance of iterator, because it can create enexpected behaviour when calling them insideforeach loop.

@webmozart
Copy link
ContributorAuthor

@Strate This API is definitely more readable. I would also prefer clear commands over setters, for example:

$form->getErrors()->includeNested()->flatten();$form->getErrors()->excludeNested()->asTree();

It's not necessary to return a new iterator, because the changed configuration would only take effect as soon asrewind() is called. What do you think?

@webmozart
Copy link
ContributorAuthor

One more thought on this: If I callgetErrors(), I expect that the result is a list of errors. It's kind of confusing that then entries in this list are able to change by calling additional methods.

@webmozart
Copy link
ContributorAuthor

An alternative solution is to splitgetErrors() intogetErrors() andgetAllErrors($flatten = true).

// This form's errors onlycount($form->getErrors());// All errorscount($form->getAllErrors());// All errors as tree$form->getAllErrors($flatten =false);

@Taluu
Copy link
Contributor

And whatif more parameters are introduced ?

AFAIC, I prefer the commands, which returns a new Iterator though, because as@webmozart said, we would expect a list of errors, not something that is manipulable... With a default set of options (the equivalent ofdeep = false andflatten = false)

@Tobion
Copy link
Contributor

If we already had named params ... ^^

@Taluu
Copy link
Contributor

Or another option would be to introduce the options not as parameters, but as an array of options :getErrors(array $options), which would containdeep,flatten, ... etc

Moreover, this would allow for different "get errors" implementation to return whatever they want with whatever options they want

@webmozart
Copy link
ContributorAuthor

@Taluu I don't foresee that we'll pass more parameters togetErrors(). I don't see the point to introduce a dynamic "options" parameter just for that (small) possibility.

@Tobion
Copy link
Contributor

Please, no "options". Worst invention ever. Most of the time you don't know which options are available. It's so magic.

@wouterj
Copy link
Member

What about a new methodgetErrorCollection which returns the iterator including the commands?

$form->getErrorCollection()->rootOnly()->asTree();$form->getErrorCollection()->rootOnly();$form->getErrorCollection()->asTree();

@webmozart
Copy link
ContributorAuthor

@wouterj That's the same approach I explained above (only with a different name). My concern stands that the returned collection is able to change by calling methods on it. This seems confusing to me. To put this into perspective, imagine the same in a different domain:

$tags =$article->getTags();// wtf?$tags->includeTagsOfRelatedArticles();

@wouterj
Copy link
Member

@webmozart I thought you were talking about the same method, while I tried to explain that we might create an extra builder method. I can see your point about the commands :)

@Strate
Copy link
Contributor

@webmozart your example withasTree() andincludeNested() really much better than setters.
What about changeable collection, I think that it is not so bad idea. Look at Doctrine's collections:

$entity->getChildren()->map( ... )// returns new collection, applied with closure.

@webmozart
Copy link
ContributorAuthor

@Strate That's a different thing. With the Doctrine collections, you apply a callback on all elements of the collection. That makes sense.

includeNested(), on the other hand, would "magically" add new elements to the collection, without indicating where they come from. That's the point I don't like.

fabpot added a commit that referenced this pull requestMar 30, 2014
…zart)This PR was submitted for the master branch but it was merged into the 2.4 branch instead (closes#10571).Discussion----------[Form] Fixed infinite tests when ICU is available| Q             | A| ------------- | ---| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -Commits-------61773de [Form] Fixed infinite tests when ICU is available3cd1c9c bug#10565 fixed typos (fabpot)584b5c0 fixed typos4a0382b fixed CS9e78a06 Merge branch '2.4'b78d174 minor#10554 framework_bundle -> framework (mvrhov)85cf7a7 framework_bundle -> frameworke505ecd feature#10370 [FrameworkBundle][Console] Add parameter descriptors (inalgnu)6aa1050 Add parameter descriptors4a06daf feature#9818 [TwigBundle] Add command to list twig functions, filters, globals and tests (Seldaek)7d61154 Add command to list twig functions, filters, globals and testscaabd41 feature#10546 [Validator] Improved ISBN validator (sprain)ec42844 Improved ISBN validator711788b fixed CScb147ec feature#10457 [Serializer] Unify usage of normalizer cache (Berdir)e7389aa Move normalizer cache to getNormalier()/getDenormalizer(), use those in normalizeObject()/denormalizeObject()5a4885e feature#9140 [Validator][Email] - Strict validation and soft dependency (egulias)3368630#1581 - Strict in Email constraint and use of Egulias\EmailValidatore0de958 Merge branch '2.4'830ab24 minor#10527 [HttpKernel] [Exception] Add UnprocessableEntityHttpException to HttpKernel Exceptions (steveYeah)304cbe9 Add UnprocessableEntityHttpException to HttpKernel Exceptions3ab2dd7 feature#10291 [Validator] New validator for UUIDs (colinodell)19931c9 Added new validator for UUIDs790ba4c feature#10534 [SwiftMailer] [MonologBundle] send error log mails from CLI (arodiss)9bb602f added explicit swiftmailer flush after ConsoleEvents::TERMINATE9dc14a5 feature#10513 [Bridge][Propel1][Form] Model choice accept custom unique column (cedriclombardot)81e94d0 Model choice accept custom unique column3b95d09 bug#10535 [Form] Fixed tests after merging pattern deprecation (stefanosala)e2d8944 Fixed tests after merging pattern deprecation58bdf84 Merge branch '2.4'3baa43b Merge branch '2.4'9e13cc0 feature#9178 made HttpFoundationRequestHandler a service (kor3k)43451e9 made HttpFoundationRequestHandler a servicefeea36d feature#10001 [Form] Deprecated max_length and pattern options (stefanosala)52c07c7 Deprecated max_length and pattern options37d484c bug#10530 [Process] Do not show output in FailedException if it was disabled (Taluu)849703a When a process fails, check if the output is enabledd6fccdd feature#9690 Using Oracle Database as ACL storage (skolodyazhnyy)5f3be0e Fix Exception messages for ObjectIdentity ObjectIdentityInterface doesn't require implementing __toString method, so we need to make sure that object can be converted to string.f66bed7 feature#10506 [Debug] sync with deprecation in DebugClassLoader (nicolas-grekas)ad88cdd feature#10509 [FrameworkBundle] add scheme option to router:match command (Tobion)e3f17f9 add scheme option to router:match commandc70a468 [Debug] sync with deprecation in DebugClassLoader6586eaa feature#10194 [Console] Added standalone PSR-3 compliant logger (dunglas)e40b34d [Console] Added standalone PSR-3 compliant logger53fec31 feature#9097 [Validator] Added hasser support for entity method validation (bicpi)e8b6978 [Validator] Added hasser support for entity method validationb14fa26 feature#10476 [Console] Fixed unsetting of setted attributes on OutputFormatterStyle (Badkill)ce0c4b4 [Console] Fixed unsetting of setted attributes on OutputFormatterStyle8170db8 feature#10473 [WebProfilerBundle] enhance logs display (nicolas-grekas)6deb4cc minor#10474 [Console] Rename Command::setProcessName to Command::setProcessTitle (lyrixx)3e6c940 [WebProfilerBundle] enhance logs display6786f6d [Console] Rename Command::setProcessName to Command::setProcessTitle71dc07c feature#10466 [Debug] add a screaming mode to ErrorHandler (nicolas-grekas)c152ccb minor#10469 fix doc block and namespace by @insekticide (cordoval)5cc817d [Debug] add a screaming mode to ErrorHandler89bde6e fix class namespace by@insekticid and doc block fix48c9985 feature#10451 [TwigBundle] Add possibility to generate absolute assets urls (romainneutron)a635c4f bug#10456 [Process] Handle idle timeout and disabled output conflict (romainneutron)ae84810 [Process] Increase tests speed40c08c6 [Process] Handle idle timeout and disable output conflict76b8851 [TwigBundle] Add possibility to generate absolute assets urls1e973b2 feature#10404 [Security] Match request based on HTTP methods in firewall config (danez)a8e9ed5 Make it possible to match the request based on HTTP methods in the firewall configurationf0c0c2c tweaked sentence120a7e9 bug#10443 [FrameworkBundle] Use DIC parameter as default host value if available (romainneutron)85a2fbf [FrameworkBundle] Use DIC parameter as default host value if availableb7c158a feature#10439 [FrameworkBundle] Add posibility to specify method and host in router:match command (romainneutron)acc66b9 [FrameworkBundle] Add posibility to specify method and host in router:match commandc14d67c [SecurityBundle] changed a hardcoded string to its constant equivalentea0598a minor#10390 [Security] Add constants for access decision strategies (c960657)1e0fea6 minor#10432 clean up framework bundle commands (cordoval)0984313 clean up commands from framework bundle5e0bb71 feature#10425 [Process] Add Process::disableOutput and Process::enableOutput methods (romainneutron)a891e14 [Process] Add Process::disableOutput and Process::enableOutput methodsc2d4be1 feature#10418 [Form] Removed "magic" from FormErrorIterator (webmozart)daac66e [Form] Removed "magic" from FormErrorIterator5b07e0a feature#10414 [Validator] Checked the constraint class in constraint validators (webmozart)ce81199 feature#9918 [Form] Changed Form::getErrors() to return an iterator and added two optional parameters $deep and $flatten (webmozart)df56c23 [Validator] Checked the constraint class in constraint validators5d6ef00 Add class constants for access decision strategies.f15ea50 minor#10376 [Component][Serializer] Add fluent interface to GetSetMethodNormalizer (alexsegura)2d42533 [Component][Serializer] Add fluent interface to GetSetMethodNormalizerbc38d76 minor#10366 [FrameworkBundle] set a default value for gc_probability (fabpot)1948d36 Merge branch '2.4'f6bc83f minor#10373 added the BC docs to the contributing file (fabpot)2f9432a added the BC docs to the contributing file69d2c8e Merge branch '2.4'e778cf1 fixed previous merge0aeb394 feature#9739 [FrameworkBundle] Extract KernelTestCase from WebTestCase (johnkary)4d31d2f fixed CSc4b8e03 feature#9852 [Translation] Added template for relative file paths in FileDumper (florianv)786c956 feature#10368 [FrameworkBundle] Added a translation:debug command (fabpot)f039bde [FrameworkBundle] fixed edge cases for translation:debug and tweaked the output5ea6437 [FrameworkBundle] refactored the built-in web servera04175e Changed placeholders623d149 Added a ConcreteDumper84f0902 [Translation] Added template for relative file paths887e6ff feature#10017 [FrameworkBundle] Add HHVM support for built-in web server (RickySu)66798ba [FrameworkBundle] Add HHVM support for built-in web server597a310 Added a translation:debug command2a15923 feature#10100 [ClassLoader] A PSR-4 compatible class loader (derrabus)6837df3 [ClassLoader] A PSR-4 compatible class loader725f7ab bug#10367 [HttpKernel] fixed serialization of the request data collector (fabpot)4a1639a feature#10314 [Serializer] added support for is.* methods in GetSetMethodNormalizer (tiraeth)480219f [Serializer] added support for is.* methods in GetSetMethodNormalizer6102f99 [HttpKernel] fixed serialization of the request data collector98c3fe7 feature#10365 [Console] deprecated TableHelper in favor of Table (fabpot)7e1bdd7 [FrameworkBundle] set a default value for gc_probability21784ce [Console] make it possible to pass a style directly to Table::setStyle()14caaec [Console] added the possibility to insert a table separator anywhere in a table output39c495f [Console] deprecated TableHelper in favor of Table77bfac7 Merge branch '2.4'aed7eab [Console] fixed some initializations in the ProgressBar class554b28d feature#10356 [Console] A better progress bar (fabpot)0d1a58c [Console] made formats even more flexible8c0022b [Console] fixed progress bar when using ANSI colors and Emojis38f7a6f [Console] fixed PHP comptability244d3b8 [Console] added a way to globally add a progress bar format or modify a built-in onea9d47eb [Console] added a way to add a custom message on a progress bar7a30e50 [Console] added support for multiline formats in ProgressBar1aa7b8c [Console] added more default placeholder formatters for the progress bar2a78a09 [Console] refactored the progress bar to allow placeholder to be extensible4e76aa3 [Console] added ProgressBar (to replace the stateful ProgressHelper class)65c9aca feature#10352 [DataCollector] Improves the readability of the collected arrays in the profiler (fabpot)dce66c9 removed double-stringification of values in the profilereede330 feature#10354 removed as many usage of the request service as possible without breaking BC (fabpot)d638369 removed as many usage of the request service as possible without breaking BC681f14b feature#10353 [Debug] ExceptionHandlerInterface to allow third party exception handlers to handle fatal errors caught by ErrorHandler (FineWolf)15d063b Create ExceptionHandlerInterface to allow third party exception handlers' to handle fatal errors1cda2d4 [HttpKernel] tweaked value exporter3f297ea Improves the readability of the collected arrays in the profiler.7baeaa2 Merge branch '2.4'a820930 bug#10308 [Debug] enhance non-PSR-0 compatibility for case mismatch test (nicolas-grekas)ca4736b [Console] fixed missing abstract keyword537f1fa minor#10315 Fix typo in method name (fixe)9c582d9 minor#10320 Fix typo in UPGRADE-3.0.md (hice3000)53c8189 Fix typo in UPGRADE-3.0.md120e197 [Debug] enhance non-PSR-0 compatibility for case mismatch test01858d3 Fixed typo in method name872647a [Security] simplified code6d926c8 minor#10311 use core StringUtils to compare hashes (steelywing)9fc01d2 use core StringUtils to compare hashes79baf8d feature#10165 [FrameworkBundle] config:dump-reference command can now dump current configuration (lyrixx)aca3271 feature#9862 [FrameworkBundle] Added configuration for additionnal request formats (gquemener)f90ba11 [FrameworkBundle] Added configuration for additionnal request formats6e9358a feature#10257 [FrameworkBundle][Console] Load command from DIC after command from bundles. (lyrixx)3e8f33a feature#10201 [Debug] error stacking + fatal screaming + case testing (nicolas-grekas)838dc7e Merge branch '2.4'5a5eb50 Merge branch '2.4'6de362b [Debug] error stacking+fatal screaming+case testing19a368e [FramworkBundle] Added config:debug command34f4ef5 [FrameworkBundle][Console] Load command from DIC after command from bundles.f828aee Merge branch '2.4'd0386e4 minor#10214 [3.0][Console] Added isVerbosity* to OutputInterface (lyrixx)816b295 [3.0][Console] Added isVerbosity* to OutputInterfacefe86efd feature#10200 [EventDispatcher] simplified code for TraceableEventDispatcher (fabpot)6dfdb97 feature#10198 [Stopwatch] Allow getting duration of events without calling stop() (jochenvdv)42e4c7b [EventDispatcher] simplified code for TraceableEventDispatcherbcb5239 bug#10199 fix ProcessPipes (nicolas-grekas)076d417 fix ProcessPipes22970e0 Merge branch '2.4'2efe461 Allow retrieving unstopped stopwatch eventsd3d097d Include running periods in durationbea1537 minor#10186 Made some HHVM-related fixes (fabpot)4c9e307 Merge branch '2.4'1e89880 Revert "minor#10160 [Translation] [Loader] Add INI_SCANNER_RAW to parse ini files (TeLiXj)"1240758 [Routing] fixed CSe223395 [Debug] fixed case differences between PHP and HHVM (classes are case-insensitive anyway in PHP)23acc24 [Debug] made order of suggestions predictable in error messages10d4d56 removed unneded test groups51d3d62 feature#8655 Adds PTY mode & convenience method mustRun() (schmittjoh)7affb71 minor#10172 [WebProfilerBundle] Use inline images instead of asset() in form-panel (Danez)12eabd8 remove unused icons7c3a3e1 minor#10160 [Translation] [Loader] Add INI_SCANNER_RAW to parse ini files (TeLiXj)f259157 Further compress iconeb6d02c Use inline images instead of asset() function5ef60f1 [Translation] [Loader] Add INI_SCANNER_RAW to parse ini filesd61f492 minor#10149 Fixed grammar in Hungarian translations (r1pp3rj4ck)7f74049 Fixed grammar in Hungarian translations6a0de7f Merge branch '2.4'774674e feature#10112 [Routing] Add createRoute method for AnnotationClassLoader (henrikbjorn)4e137cc feature#10064 [TwigBridge] Added support for json format in twig:lint command (lyrixx)2e2a65c Merge branch '2.4'78d49fb minor#10081 [FrameworkBundle] Pretty Ppint json ouput of yaml:lint command (lyrixx)97404b3 Add createRoute method for AnnotationClassLoader689e9bf [FrameworkBundle] Pretty Ppint json ouput of yaml:lint command4d2f94a [TwigBridge] Added support for json format in twig:lint command621f991 [TwigBridge] Cleaned documentation of twig:lint command4ad343b feature#10005 [Security] Added named encoders to EncoderFactory (tamirvs)c69e2ca [Security] Added named encoders to EncoderFactorya207006 minor#9996 [Routing] Added an extension point for globals in AnnotationClassLoader (lyrixx)e1b85db feature#9405 [FrameworkBundle] Added a helper method to create AccessDeniedException (klaussilveira)183d0ec [FrameworkBundle] Added a helper method to create AccessDeniedException7da803f minor#10021 [WebProfilerBundle] Simplified session storage implementation (bschussek)cec05bf [WebProfilerBundle] Simplified session storage implementationfff29a3 feature#9967 Form debugger storage (WouterJ)744da7f Form debugger storage916420f feature#9980 [Routing][FrameworkBundle] Deprecated the apache dumper (jakzal)6258cfa [Routing][FrameworkBundle] Deprecated the apache dumper6b3fbb5 [Form] Changed the default value of $flatten in Form::getErrors() to truea9268c4 [Form] Changed Form::getErrors() to return an iterator and added two optional parameters $deep and $flatten8ea3a43 feature#9993 [Form] Errors now reference the field they were added to and the violation/exception that caused them (bschussek)8f7524e [Routing] Added an extension point for globals in AnnotationClassLoaderc8a0ee6 [Form] Errors now reference the field they were added to and the violation/exception that caused them147c82b minor#9972 Upgrade File for 2.5 (Danez)fefcf41 Added upgrade info for#9601c833518 feature#9776 [Console] Added the possibility to set a different default command (danielcsgomes)418de05 [Console] Added the possibility to set a different default command79bea0a feature#9966 added feedback to the cache:clear command (fabpot)f2261da [FrameworkBundle] simplified codea1f6411 [FrameworkBundle] added feedback in cache:clear0af3ca3 Merge branch '2.4'ef12af9 feature#9963 [HttpFoundation] JsonResponse::setEncodingOptions accepts also integer (stloyd)f8bc3b2 [HttpFoundation] JsonResponse::setEncodingOptions accepts also integer74fb207 feature#9915 [HttpFoundation] Add ability to change JSON encoding options (stloyd)89f4784 [HttpFoundation] Add ability to change JSON encoding optionsa596ba3 feature#8375 [OptionsResolver] Allow giving a callback as an allowedValue to OptionsResolver (marekkalnik)07d1d30 Allow giving a callback as an allowedValue to OptionsResolverf3670b4 feature#9666 [FrameworkBundle] Added a yaml:lint command (lyrixx)9c06b27 [FrameworkBundle] Added yaml:lint command8cd8ec0 Remove usage of deprecated _scheme in Routing Component6063b49 Merge branch '2.4'd3b28dc minor#9944 [FrameworkBundle] Update composer.json to account for#9792 (realityking)f1efd16 [FrameworkBundle] Update composer.json to account for#9792f499094 minor#9880 test for class route annotation (ewgRa)60c2140 minor#9931 Removed all codeCoverageIgnore annotations from the code (stof)ac94ddb test for class route annotation4248169 Removed all codeCoverageIgnore annotations from the code2c059ee feature#9926 [Finder] Added GLOB_BRACE support in Finder::in() method (jakzal)a12db9b Merge branch '2.4'e2698fc [Finder] Included GLOB_BRACE support in the CHANGELOG.30814d3 [Finder] Added a test case for the GLOB_BRACE in Finder:in().da67f5d [Finder] Added GLOB_BRACE support in Finder::in() method64c7095 removed unneeded use statements18d69a8 Merge branch '2.4'df6b0b8 bug#9917 [HttpFoundation] fixed PHP warnings (fabpot)cf71e22 [HttpFoundation] fixed PHP warnings410d399 fixed PSR00defad9 Merge branch '2.4'8850456 Merge branch '2.4'702e2a4 feature#9855 [Twig] Decouple Twig commands from the Famework (GromNaN)907748d [Twig] Decouple Twig commands from the Famework3203793 added a missing namespace use statement28a8400 feature#9251 [WIP] [FrameworkBundle] removed some more dependencies on the request service (fabpot)9eaed35 feature#9857 Form Debugger JavaScript improvements (WouterJ)d9bb4ff Reverted Sfjs.toggle change6aaefd8 Reverted new imageec2496f Fixed asset function624a09f Enlarged the clickable area of the toggle button in the form tree0ff2632 Moved toggle icon behind the headlines in the form debugger8ba8db2 Changed toggle color back to blue and made headlines in the form debugger clickableb8358e3 Added "use strict" statements0936694 Inverted toggler images and improved button coloring64a3442 Improved JavaScript of the form debugger0908155 Vertically centered the icons in the form tree9dc2cde Fixed CS6eb1e49 Added error badgeb02c227 Made sections collapsableb223527 Improved form treec19ff6f Expand tree96c4486 minor#9374 Change of scope (djoos)335bee2 Change of scope5079f34 feature#9892 [Validator] Added Doctrine cache (florianv)3c4de45 [Validator] Added Doctrine cachec15175a Merge branch '2.4'9fbe148 feature#9590 WebTestCase: Assume relative KERNEL_DIR is relative to phpunit.xml[.dist]? (mpdude)4f3d502 [FrameworkBundle] removed some more dependencies on the request servicefd5a2d0 Merge branch '2.4'7d80045 Merge branch '2.4'f063108 feature#9814 [EventDispatcher] Added TraceableEventDispatcher from HttpKernel (florianv)9a90e06 [EventDispatcher] Added TraceableEventDispatcher from HttpKernel0b0c431 feature#9833 [Bridge] [DoctrineExtension] Allow cache drivers that are not an EM's child (FabioBatSilva)f0d9af0 feature#9876 [Serializer] error handling inconsistencies fixed in the serializer decoders (fabpot)a1ab939 [Serializer] fixed CS6d9f0be Json encoder classes now throws UnexpectedValueException as XML classesf9dff06 Merge branch '2.4'f132197 feature#9360 [Finder] Fix finder date constraints and tests (ruian)c6b1c74 feature#9837 [Form] added getter to transformer chain (cordoval)7a9ab2c feature#8305 Added MutableAclProvider::deleteSecurityIdentity (lavoiesl)a4d423e minor#8423 Update LocaleTest.php (mikemeier)572126b Update LocaleTest.php694bd72 Merge branch '2.4'6a51831 feature#9846 [Console] hide output of ProgressHelper when isDecorated is false (kbond)006cb81 [Console] show no output in ProgressHelper when isDecorated is false (fixes#9511)8d39213 feature#8650 [Security][Acl] Add MutableAclProvider::updateUserSecurityIdentity (lemoinem)2b7af12 feature#9843 [PropertyAccess] Allowed non alphanumeric chars in object properties (florianv)20d4eb6 [PropertyAccess] Allowed non alphanumeric chars in object propertiesda53d92 [Security][Acl]Fix#5787 : Add MutableAclProvider::updateUserSecurityIdentity3565d96 added getter to transformer chainc4f14fb Extract new base test class KernelTestClass7528e4c Allow cache drivers that are not an EM's childc0e4c4a bug#9816 [DependencyInjection]fixes#9815 Syntax error in PHP dumper (realityking)e00b0f3 [DependencyInjection]fixes#9815 Syntax error in PHP dumperbaaf9b6 feature#9792 [EventDispatcher][HttpKernel] Move RegisterListenersPass from HttpKernel to EventDispatcher. (realityking)89b8e0a [EventDispatcher][HttpKernel] Move RegisterListenersPass from HttpKernel to EventDispatcher.ad4d6f7 feature#9668 [DepdencyInjection] forgot to add definition of dumped container member variable parameters (cordoval)5b02d3f [DepdencyInjection] forgot to add definition of dumped container member variable parameters8b08888 bug#9812 [DependencyInjection] fix a regression introduced in#9807 (realityking)0d78776 [DependencyInjection] fix a regression introduced in#980711434de minor#9802 [HttpKernel] Remove FrameworkBundle dependency in BundleTest (florianv)0604220 feature#9780 [Console] Added a way to set the process title (lyrixx)20a064f [HttpKernel] Remove FrameworkBundle dependency in BundleTest375a2c7 minor#9807 [DependencyInjection] Avoid call_user_func in dumped containers. (realityking)be1eaaa [DependencyInjection] Avoid call_user_func in dumped containers.204a25e [Console] Added a way to set the process title67ae8fa feature#8224 [Form][2.4] added an option for multiple files upload (closes#1400) (bamarni)c8c6448 [Form][2.4] added an option for multiple files upload (closes#1400)c1051d5 fixed CSe660bc9 feature#9773 [Form] Added delete_empty option to allow proper emptyData handling of collections (peterrehm)8bdb7a0 [Form] Added delete_empty option to allow proper emptyData handling of collections21ecad1 minor#9723 [Security] [Acl] [MaskBuilder] Refactor common code and reduce nesting (djlambert)c0a7e1b feature#9791 [DependencyInjection] added support for inlining Configurators (realityking)4e9aa07 [DependencyInjection] added support for inlining Configurators8e1f854 feature#9779 [Debug] Added UndefinedMethodFatalErrorHandler (lyrixx)74d13e3 [Debug] Added UndefinedMethodFatalErrorHandler6764f91 Merge branch '2.4'de57903 Merge branch '2.4'7d85809 Refactor common code and reduce nesting5e37fc8 Revert "encourage the running of coverage"bb73852 encourage the running of coveragee5362c1 Merge branch '2.4'db4f551 Merge branch '2.4'ce64435 minor#9594 [Security] Fixed typos/CS/PHPDoc (pborreli)1fcc7c5 Merge branch '2.4'05dc0e1 Consider KERNEL_DIR setting as relative to the PhpUnit XML file if it does not point to a directory (relative to the current cwd)4aab341 updated version to 2.5e1110de Fixed typos/CS/PHPDoc4ccafa6 Fix finder date constraints and testsdbd264a adds cache for isPtySupported()6c11207 attempts to fix tests on Travis2ff1870 adds convenience method mustRun53441aa adds support for PTY modebdbbe58 [Security][Acl] Issue#5787 : Added MutableAclProvider::deleteSecurityIdentity
@odoucet
Copy link

I think this BC break should be stated clearly in official documentation (maybe here :http://symfony.com/doc/master/book/forms.html ?). I hit this bug because I was doing this :

$errors = $form->getErrors();if (is_array($errors)) { ... }

As it is no longer an array, code stopped working after updating from 2.4.5 to 2.5.0

@wouterj
Copy link
Member

BC breaks are documented in the changelog and this one exists in the CHANGELOG-2.5 file, so imo everything is correct.

@jonmchan
Copy link

How is the new deep=true argument supposed to be used? I have a field validation error, and I can get the error from $form->getErrors(true), but there is no information in the FormError object that ties it back to the field, so all I have is the error message - "This value should not be blank." Not really helpful without knowing which field shouldn't be blank...

@Tobion
Copy link
Contributor

@jonmchan there is a second argumentflatten. Have you used that?

@jonmchan
Copy link

@Tobion - I get the same result with flatten=true or false.

print_r($form->getErrors(true,true);Array(    [0] => Symfony\Component\Form\FormError Object        (            [message:Symfony\Component\Form\FormError:private] => This value should not be blank.            [messageTemplate:protected] => This value should not be blank.            [messageParameters:protected] => Array                (                )            [messagePluralization:protected] =>         ))

Nothing that I can use to tell me which field contains the error.

@wouterj
Copy link
Member

@jonmchan do you meandeep=true ordeep=false? Indeep=true, you have access to theFormErrorIterator which contains information about the form (the->form property) and thus the name of the field (using->form->getName()).

For an example, seehttps://github.com/symfony/symfony/pull/9918/files#diff-d2d282c9214f4b80194de9d815412a1dR81-101

weaverryan added a commit to symfony/symfony-docs that referenced this pull requestNov 20, 2014
…rors() (xabbuh)This PR was merged into the 2.5 branch.Discussion----------[Components][Form] document $deep and $flatten of getErrors()| Q             | A| ------------- | ---| Doc fix?      | no| New docs?     | yes (symfony/symfony#9918)| Applies to    | 2.5+| Fixed tickets |#3660This is based on#4168.Commits-------0245e91 [Form] document $deep and $flatten of getErrors()4221db8 describe how to access form errors
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

14 participants
@webmozart@ahilles107@alexsegura@fabpot@Djeg@Seb33300@wouterj@hhamon@Strate@Taluu@Tobion@odoucet@jonmchan@stof

[8]ページ先頭

©2009-2025 Movatter.jp