![]() The reason was that the multi-value fields were loaded using ajax and were validated after the single value fields. For most of the fields it was working correctly but when the mutli-value custom form elements were validated the order of all the single value field errors were inconsistent with the order on the form. This was all working nicely but the problem was that all the validation errors were showing in the order they are validated not in the order in which they are displayed on the form. If there are errors set the form errors else store objects in local storage.validate the objects using Symfony validation component.hydrate the model objects from user input and.pass the model object to the form factory, which derives the form API fields and.In this post I'll explain a process in which we can achieve just that - keeping the form error messages in the same order as the form fields. Whenever you are working with complex multistep forms and updating a sub-form based on user input then you can't exactly show the form errors in the order in which the fields appeared on the form. To convert this data model into form fields we wrote a form factory and connected it all together using the service container module. This is good because we can write all the validation separately and test it using phpunit without bootstrapping Drupal. This gives us the benefit of validating the form fields using the Symfony validation component.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |