views:

48

answers:

1

Hi guys, I have a question regarding drupal 6 forms.

I have 4 tables: location[locationid, name]; package[packageid, name], person[personid, name, locationid, address, etc...] pickup[pickupid, personid, packageid, locationid, _pickup_day_,...].

I've made forms and form_submit for the three tables: location, package, person (simple CRUD as usual). Now, I want to make a form to submit data into the "pickup" table. The twist is, the only data the user needs to input is the "pickup_day" field, which can be 1 or 0 (monday or tuesday). So I imagine when I go to the pickups url, I'll see a list of output fields:

firstname | lastname | location | pickup day | package type

first1 last1 church1 select box (monday/tuesday) select box (type1/type2/type3)

first2 last2 church1 select box (monday/tuesday) select box (type1/type2/type3)

first3 last3 church1 select box (monday/tuesday) select box (type1/type2/type3)

[submit button]

When its submitted, the data goes into "pickup" table.

I'm trying to figure how to render the select boxes while outputting person's information.

(Just an aside, would it be possible to have a search before seeing the form...for example I search for location to be church1, then I'll see all the users at that location in a form as above)

All help is very much appreciated...even pointing to a module that does something similar to this is fine... I just need to get some hints on how people have approached this. Much thanks!


End goal: So, basically, I have a number of people in my database. Each person is assigned a location where they can go and pickup food. I want to record each pickup for each week for each person. So I have a pickups table to do that. So I'm trying to make a single form (pickups), where I can go to and update who picked up what...on what day (Monday or Tuesday). But so in this form, I need to show all the people registered for a particular location. So lets say a person is registered for a church called Church 1...I want to search for the Church 1 location, then all the people who are registered for that location comes up row by row. Then I can select which day each person picked up food and what type of food they picked up...and click submit. Then I'll run a query against my database to add this information.

The big deal I guess is that instead of making a form for each person (for each row), I just make one form and when the form is submitted everyone will be added to the "pickup" table with the appropriate day and item they picked up.

A: 

I would suggest you look at the form API's built-in AHAH support. You can find more information here: http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#ahah. Assuming I understand your question correctly, this is a fairly typical ajax/ahah form situation; an element in your form triggers the creation of new form elements.

For example, you can create a select box of locations. Once a location is selected (#ahah['event'] => 'change'), you can make a callback to a menu location (#ahah['path'] => path/to/callback) which can generate the new form elements to add, in this case select boxes for the persons and/or packages associated with that location.

You could also do something similar using search instead of a select element.

emmychan
Thanks, but I don't really think I'll need ajax functionality here...all I need to do is submit data and redirect. My problem is that I need to visually display data from different tables before submitting data to a new table.
berto77