如何参考无效字段获取Symfony2表单验证错误列表?

As Symfony2 Form component with tight integration with the validation component is extremely powerful, I have hard times understanding how I can get the list of validation errors at PHP side with proper reference to the invalid field. By "reference", I mean some hint that I can further get the field and it's ID (like with $form->get($failedChild)->vars['id'] or something).

$form->getErrors() returns the list of the errors, but this array of FormErrors does not include any reference to the field that is invalid.

I found a Gist that shows something like that, but at least on 2.3 or 2.4 all errors are still bound to the main form.

error_bubbling option does not change the behavior as I first thought it would.


Update #1

In the end, I'd like to receive a JSON representation of all form errors and return it back to the client. A sample JSON would be something like

{
    "invalid_field_id": "This field has invalid value"
}

The ID of the field can be received over $field->vars['id'] but it seems that all validation errors are returned in $form->getErrors() instead of $field->getErrors()

You can use $form->getErrorsAsString() to get a human-readable representation of your errors. These errors are mapped to fields, unless the error can not be attached to a field, or error_bubbling is set to true.