If the form which the entityreference is in contains an error (for example a required field is not filled) and you select a value in the entityreference, then the value is NOT trimmed. It seems as if the alter hook is not called at all in this case?

Any ideas for the reason?

Comments

Anybody’s picture

Priority: Normal » Critical

Set this problem to critical, because it's not possible to correctly submit the form anymore, because the whole text including "(X)" is filled into the hidden field.

2pha’s picture

Hmm, I have this problem too.
I ended up a small bit of js to get this functionality instead of using this module. https://2pha.com/blog/removing-entity-id-drupal-entity-reference-fields