score:0

Accepted answer

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
  )
);

Related Query

More Query from same tag