0

I'm building a Drupal site that uses nodes to display a number of high value products. There are no e-commerce features due to the high value of the products being offered for sale, but the client wants a quote form on each product (node) page so that a potential buyer can enter some brief information and click to send a quote request for the item that they are viewing.

To make it clear, I have a content type called "Product", and I want this quote request form to be on each page and pre-loaded with the name of the product that that page is listing... it's not important whether the form is embedded in the node itself or displayed in a block, but it is important that the name of the product be preloaded in the form.

Following the form submission, ideally it would send an email to the website contact address.

I've considered using the entity form module and embedding the option to select a form in a node, but I don't want the client to have to manually create a form for each node.

Any ideas about how to create this functionality?

3
  • 3
    You can use webform module and webform_references(my contribution :P) module to keep the nid reference. Dec 20, 2014 at 11:42
  • Go through bioreclamationivt.com Use webform
    – Rupesh
    Dec 20, 2014 at 11:43
  • 1
    Sumit Madan: Your module looks interesting, are you suggesting I have the webform in a block on the page, and it would draw the node id from whatever page I'm on still? Or would I have to embed the form in the node somehow?
    – JamiePatt
    Dec 20, 2014 at 11:48

2 Answers 2

1

Entity Forms are, IMO, a long shot.

1. Webform module

You can use Webform module, and add an Option list (HTML select list) field to the webform, and autopopulate it with a URL parameter. Webform module supports populating the field value automatically from any $_GET, $_COOKIE, or $_SERVER value.

For the select list values, you can use a View to build the list of Product nodes.

2. Entity Forms

Since you already have an Entity Form, you can do it with the traditional field approach. Similar to the webform's select lists, you can create a View to list all Product nodes. Entity Reference module supports Option (radio, select, checkboxes) field type, with the options fetched from a View. You can use Entity Reference Prepopulate module to populate the Product node from a URL parameter.

3. Custom module

Either way above, you will have to use some modules. If you are OK to create a custom module, you can do it with a little coding as well. Be prepared to go through a little bit learning and conventions first. This is a nice guide to get you started.

You can do this easily with an EntityFieldQuery to fetch the eligible nodes list, and then setting the #default_value in hook_form_alter hook.

0

I've done something similar for a client using the Webform module. In my case it's sufficient to only know from which page (i.e., node) the form was submitted, therefore I've adjusted the e-mail template and added the token [current-page:url] to get the page's address.

However, if you need to store the data along with the submission result, you can add a hidden component and use the [current-page:url] token as its default value. I assume the Webform Rules module will be your best option, when you want to convert the submission result (i.e., the current page's url) into another value (e.g., the node's id).

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.