2

Here is a content type structure called Bill :

  • Bill_ID => Int
  • Bill_Date => Date
  • Services => Entity Reference (Target Type : Node , Target Bundle : Service , Widget : Auto-complete)

The only problem is that the end user shouldn't be allowed to make a reference to an unpublished Service.

So how can we limit user to only make a reference to published contents ?

  • This is the default functionality, an non published node cannot be referenced as per default functionality of Drupal. Have you used some module or wrote some custom text which is enabling you to reference unpublished nodes?? – Dev Nov 25 '15 at 12:53
  • I created a Service then unpublished it , in Bill creating form it was one o the member which showed up . No code or module was added. – Alireza Tabatabaeian Nov 25 '15 at 13:04
5

Create a view with entity reference display. Click add and in the drop down you will see entity reference.

Now create a view and create a filters normally as you do. Now go to your content type services field settings and click views instead of simple selectionenter image description here

Select the views you created and your options will be limited to the result of the view.

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.