score:0
after playing around i finally got my solution. since the validation tries to validate the first element in my collection e.g. data.translations[0].body
i needed just to provide the correct property path for it to know.
$builder->add(
'translations', articletranslationtype::class, array(
'data' => new articletranslation(),
'mapped' => false,
'label' => false,
'property_path' => 'translations[0]' //first element of collection
)
);
this maps the error messages to the corresponding field.
score:1
what you're looking for is the error_bubbling formtype field option.
error_bubbling
type: boolean
default: false
unless the form is compound.
if true
, any errors for this field will be passed to the parent field or form. for example, if set to true
on a normal field, any errors for that field will be attached to the main form, not to the specific field.
your articletranslationtype is compound
, therefore error_bubbling defaults to true
.
the following should do the trick.
$builder->add(
'translations', articletranslationtype::class, array(
'data' => new articletranslation(),
'error_bubbling' => false,
'mapped' => false,
'label' => false
)
);
Source: stackoverflow.com
Related Query
- Symfony Validation: Error message not showing at associated field
- Symfony Validation Error Message for Missing Required Form Field
- symfony form validation message for hidden field not shown
- Symfony 2 rendering form error not associated with form field
- Cannot retrieve error message using Symfony HttpClient if the response is not "ok"
- Symfony EasyAdmin 3.x ManyToMany error when adding : The Doctrine type of the .... field is "4", which is not supported by EasyAdmin yet
- Symfony2 form field not updated when validation error occurs
- How to show validation error message in front of each field in symfony2
- Symfony 2 own Field Type - always "This value is not valid" error
- Symfony 5 debug tool bar not showing on error page
- Symfony form unchanged field returns validation type error
- Symfony 2 repeated field validation duplicated message
- How to properly position an HTML5 form validation error message after hiding an input field with jQuery?
- Symfony - decimal number in integer type field causes no validation error
- Symfony2 form validation - how display only first error message per field
- Symfony 5 Constraint Validation : Customize error message
- Symfony2 form errors not showing, UniqueEntity error message not shown next to the corresponding field
- Symfony 6 my login form does not connect me no error message
- Symfony 3 - Form validation error fields not displaying
- Symfony form with EntityType field yields a 'This value should not be blank' error if the field has a Valid() contraint in the object class
- Symfony Forms: Custom error message without changing the validation rule in validation.yml
- Symfony Unique Entity error message not displaying
- Symfony : form error message not displayed
- Symfony 4 form validation not showing all errors
- Symfony 5.3 - FormBuilder RepeatedType - Error message is not shown in form when password not the same
- symfony error message in form when using custom validation method
- Symfony Sonata OneToMany, Sum or Total of a field is not showing in the Admin List
- Form load entity by input and add not found error message to specific field
- Symfony 2 Number Field with validation constraint not working
- Pluralization is not working on form's validation message in Symfony 2.3
More Query from same tag
- How to add if into form builder in Symfony
- Symfony 2.6: Error loading web debug toolbar only when xdebug cookie not set
- Symfony 3 and nginx
- Symfony2 architecture
- Backbone.js and Symfony2 form validation
- Can't create database with postgres and docker
- Persist collection in one-to-many / many-to-one association
- How to add non-persistent field to form?
- Access linked object in Twig
- Get value from EntityType Symfony
- Symfony normalizing array of strings into an Entity
- Symfony3 queryBuilder how to search with OR and how to search for substring?
- Symfony2.8 : get User Object from form
- Getting clone method called on non-object when specing Symfony command that uses SymfonyStyle for styled output
- symfony flex composer InvalidArgumentException
- What is the best practice for building choices list
- Cloning Sylius using composer
- Symfony2 form data_class factory for creating the data object
- Multiple file upload not saving each path in database
- How to implement FOSUserBundle register form in other pages
- Symfony Extend Authentication Timeout on Request
- ERR_TOO_MANY_REDIRECTS + When redirecting anonymous user
- How to display a collection of blank form?
- Registering new users via OAuth2 : what to set as user identifier for future log ins?
- Symfony 2 relations issue
- doctrine getRepository errors
- Difficulty to Manage data with payum Bundle
- Custom role class name in Symfony2
- How to filter relationship in doctrine
- Doctrine PHPStan entity relation Collection never written, only read