Domanda

I am probably asking a noob question... however:

I have a Drupal site that the customer has a web form where anonymous users can fill in to order some posters (there is 3 to choose from). These are free and at the moment they user just states in the body of a textarea what posters they want.

The site owner wants to now add more posters and now wants the ability to have each poster listed in the web form with a field for quantity next to them.

When the web for is submitted it will post the node title and quantity to the web form along with the required information.

I have researched using UC but it's too much of a eCom solution for such a simple requirement. I also looked at SimpleCart, Flag and Session favorites, all of which aren't really what I need.

So I am looking for a simple way to itterate over all the "Poster" content types, and display them on the webform page with a quantity numerical field to be submitted with the web form for each poster.

Currently I have:

CCK Poster

  • Title
  • Image

WebForm OrderPoster

  • Name
  • Email
  • Address
  • Details

What I am looking for is a page that does the following:

WebForm OrderPosters:

  • Poster 1 [form qty text input for poster 1]
  • Poster 2 [form qty text input for poster 2]
  • Poster 3 [form qty text input for poster 3]
  • ...
  • Poster n [form qty text input for posters n]

  • Name

  • Email
  • Address
  • Details

I'd imagine there is a simple way to do this, but I can't seem to find articles of customizing "WebForm" forms. Any help would be much appreciated.

È stato utile?

Soluzione

I don't know of any way to programmatically add components to a webform. I've used them a lot in my sites, but if you are going to do something like what you said you have to go the custom module route. If you did want to keep the webform you could program your own form component to do exactly what you want, but docs are scarce for that too. I would start by looking at some of the built-in components to get an idea of what needs to be done and then make my own.

Personally I would implement a custom module to do this. You would need to use hook_menu() and then create a callback to build this form. While building the form you could easily loop through the available posters and create the form elements. The submit function would then save to a database table and if needed, it could also post to a payment gateway when your customer wants people to pay for the posters.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top