In my project, there is a content type 'song' containing an entity reference field to reference content type 'playlist'. More than one user can edit a 'song' to add it to their own 'playlist's.

Now, when one user updates a 'song' node creating his/her references in the node edit form, the previous references made by another user are deleted. In the node edit form, the field is formatted through an entity reference view showing a list of 'playlist's only created by the current user. The number of values for the entity reference field is set to unlimited.

What would be a good and server-friendly approach to solve this problem keeping in mind that there can be an unlimited number of previous references made by other users?

2 Answers 2


Edit the field and set number of values to be unlimited. If you want more control and flexibility you could put the entity reference within a field collection.

  • Thanks for your answer, but the number of values is already set to unlimited. I edited the second paragraph of my question to add some more details about it.
    – user30612
    Commented Jul 8, 2014 at 15:11
  • The previously selected items are being removed because drupal sees the the list being produced buy the view as the allowed options for validation. You should be able to get round this you can use hook_form_alter in a custom module but you might be better of putting the reference on the playlist content type or using the flag module
    – pete80
    Commented Jul 8, 2014 at 16:13
  • Thanks a lot again. Actually, the reference is also on playlist content type and I'm using corresponding node reference module to keep them in sync. I needed to add the reference from the song view page and that's why I put the reference in the 'song' content type too. If you can give me some hints about how to get around this using hook_form_alter I can proceed to accept your answer. Also, I know how to use flag for creating a bookmark like feature. But, is it possible to create new playlists and add songs into them by a user using the flag module?
    – user30612
    Commented Jul 8, 2014 at 17:14

In your current setup it's logical to only have entity reference to song from play list content type. Having the reference from song to playlist is redundant. You can always have view showing all the playlists that the song belongs to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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