I've two content-types "Book" & "Review". I want users of role reviewers to add reviews to any book they desire.

How I did it?:

I've added entity-reference to Book from Review with (auto-complete) widget. This just allows reviewers to add review node and select book from auto-complete. Who does that way? I'm not satisfied with it.

How I want it:

I've a page for every book /book-details/title-of-the-book, where I want to provide a link/button which says Add Review and then it should show them the fields of Review content-type and reviewer fills it and submits. His review is submitted. and the same page shows list of all reviews for that book.

How to achieve this in drupal-7?

2 Answers 2


Add review content type form while viewing book content type is viewed by using hook_nodeapi().

  1. Create one field on review content type(node reference of book node).
  2. Add that node_form in book content type view with $form_state of the book node id.
  3. Create a view for review list with a filter of book content type and use this block under book content type view.
  1. Create an entity reference field called Book (field_book) on the content type Review
  2. Download and enable Advanced Form Edit
  3. Create a block for your Add review form at admin/settings/advanced-form-blocks (type of the block: add, content type: Review
  4. Now add this block to your region at admin/structure/block. Set it to appear under the content region and make. In the visibility settings set it to only be visible on the book content type
  5. Create a custom module enable it and paste in the following code in the mymodule.module file:


  function MYMODULE_form_alter(&$form, $form_state, $form_id) {
    if ($form_id == 'review_node_form') {
      if (arg(0) == 'node') {
        $nid = arg(1);
        $form['field_bookie'][LANGUAGE_NONE]['#default_value'][$nid] = $nid;
        $form['ajax-submit']['#ajax']['callback'] = 'MYMODULE_create_callback';

function MYMODULE_create_callback($form, &$form_state) {
  return $form;

Finally create a block view with a filter on content type review and add a contextual filter for Content: Book (Select "Provide default value" and "node ID from URL")

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.