1

I create a form where users can submit their opinion and votes about nodes that they select from an entity referenced list. How can I assign the votes to the entities that apoear on this list?

eg. "Review" content type are completed by auth users. In "review" form there are 2 fields "class" and "teacher" where the user can select from an list of nodes "class" and "teacher" content types. After the user select the "class" and "teacher" then must vote (voteapi & rate) and complete an opinion (textarea) about the nodes he selects.

1

Use the Inline Entity form, which allows you to set a view with the list of nodes and modify them directly (you would set the voting in the voted node e.g., the class or teacher, in your example).

The plan is for you to set up the Review content type with a Entity Reference field. This will allow you reference a View where you can set up your Class and Teacher Nodes.

You need the following Modules: Five Star and Voting Api (Which you already have) Views, Entity API, Inline Entity Form.

The way I understand your process is as follows:

  • You have a set of classes and a teachers
  • You intend to make available a set of these classes and teachers to a different content type (this is review), to generate votes for that class and/or teacher
  • The number of classes/teachers available for that review to emit a vote from is unspecified (may be all or a subset of them)

To go about this you need to have the following:

  • Voting fields in class and teacher content types
  • Create a Entity Reference View which displays the list of nodes you need (one for each, selecting their respective content types).
  • Add a Entity Reference field in the review content type with the Inline entity form - multiple values widget.
  • While setting the field:
    • Check Allow users to add existing nodes, so that they can select the class/teacher from your current list.
    • Select in Entity Selection: Views: Filter by an entity reference view
    • Select in View used to select the entities the view you would prefer for that field (teacher or class)

You should be able to add the classes/teachers you want to vote for. Also, you can control the entities shown by the view (so you could add context filters). Be mindful of setting the votes so you can vote while editing.

  • From what I see it generate the entire node/add form inside. Or it is an way to add just the voting stars widget in "inline entity form" and the user don't have an edit button of the node. – AlexB Jun 16 '16 at 6:42
  • I edited the question for greater detail. – Antonio Hernandez Jun 16 '16 at 15:40

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.