0

I'm having problems with a required field that is an entity reference. This is my case:

I have a content type advertisement that has an entity reference product, what is an autocomplete widget. The entity reference is a required field (so when it's empty you have to fill something in).

When you start to type in the text field you get a list of suggestions to select from. But you can also type some text and DON'T select a suggestion, the form will submit and the content will be created. I don't want that. I would like to create an error that when you don't select one from the list you receive an error.

What happens when you don't select a suggestion: the advertisement is created but the product is empty!

Is there a way that I can create an error when you don't select one from the list?

  • What you've just described is rather strange. The entity reference widget should be able to reference just already existing entities and if non-existent entity is entered it should throw an form error. Is the field really set up as required (i.e. is there a red star next to it?) – Petrroll Aug 12 '14 at 14:49
  • Either way, if I write something nonsensical (e.g. not matching any entity) into the field I get "There are no entities matching "sdfsdfsdf"" If I leave it empty I get "TST_aut field is required." error. So I'd suggest you to make sure you use the last version of entity reference (I believe there was a bug in earlier versions that behaved like this). – Petrroll Aug 12 '14 at 15:02
2

Are you sure you are using the Autocomplete widget or are you using the Autocomplete (Tags Style)? I believe tags style allows for an entity to be created like taxonomy term.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.