Edit: Updated title to make it less confusing.
Second Edit: Edited title again, now a simple? php form question involving selection lists. Skip to the last few posts if you want to laugh at my ignorance.
I set up a vanilla site, installed CCK, Views, Date, and Calendar and have been able to easily set up the means to create events and have them visible in a calendar. Yay.
Here is where I need to continue: I want people to be able to sign up for events, with specific jobs at such events.
So, as a very simplistic example - let's say I want to create a BBQ event, and have people sign up to bring certain supplies.
Maybe we have a few people bring cola and assorted beverages, others may bring salad and dessert, others may bring other sides, others may bring some main course stuff.
Also, if they are bringing other people with them, it would be cool to allow them to sign up using their same login but for another job.
What would be the easiest way to accomplish this? Or, what keywords should I use to search to find relevant videos/articles/wikis/posts? My googlefu hasn't been strong in the past few days.
Thanks!
Comments
The more I think about this,
The more I think about this, the more I think that
i) If we want to have someone sign up for a specific job, and keep doing that job until they choose to change it and;
ii) If we want to have someone be able to have a second (or third, etc. etc.) job signed up as well
Then I would like to believe the best way to handle this would be to have such information stored within the user's profile. Then when they go to sign up, this information can be pulled from the user's profile as default, and they can change it as requested.
I have a feeling this is not going to be a minor feature.
OK, so I have been playing
OK, so I have been playing around with the standard Drupal Profile module and am encouraged.
Set up the fields in the user's profile, and for the moment it looks good.
Now, if memory serves correctly, the signup module will load the user's email address automatically from the user's profile. So, the signup module can indeed pull such information from the profile.
With luck I am going to see if we can get it to load this other information too. Would work perfectly.
Seems like the latest signup
Seems like the latest signup version already has what is needed in the theme/signup_form.inc with some information on how to do exactly what I want.
However, being a phptemplate newcomer, I am searching to figure out how to pull selection types into the signup.
In the example, they use textfields
$form['signup_form_data']['fieldname'] = array(
'#type' => 'textfield',
'#title' => t('fieldname'),
'#size' => 40, '#maxlength' => 64,
);
But I need to figure out how to do selection lists...
So I found some references to
So I found some references to selection lists in the form api quickstart guide, but obviously my lack of base knowledge is not making this easy.
Switched to:
$form['signup_form_data']['list'] = array(
'#type' => 'select',
'#title' => t('list'),
);
But I get an error for every selection list (all are non-empty)
warning: Invalid argument supplied for foreach() in .../form.inc on line 1434.
Loaded up form.inc and
Loaded up form.inc and frankly that is of little help.
Am now stumped.
Anyone help with this (I am guessing easy) issue?
Found the Drupal Form API
Found the Drupal Form API page and noticed that when they are dealing with selects they list all of the options again in a nested array. Followed that approach to no avail.
$form['signup_form_data']['Topic'] = array(
'#type' => 'select',
'#title' => t('Topic'),
'#options' => array(
'generic option' => t('generic option'),
'generic option2' => t('generic option2'),
),
);
Still same error.
I am thinking the proper way to do it would be to populate the options array from the PROFILE information...hmm how can this be done?
Changed it
Changed it to
$form['signup_form_data']['Topic'] = array(
'#type' => 'select',
'#title' => t('Topic'),
'#options' => array(),
);
and now no more errors!
Problem is, that the profile information isn't being collected either. Hmm..
This is signup module
This appears to be somewhat signup-module specific, so I will post an issue over there to see if I can get some specialized help.
Well...
Haven't had any luck with those involved with the signup module (they are likely busy with other things, and it hasn't been a very long time), but I thought I would throw this out there anyway.
I notice that in my DB it is the profile_fields and profile_values tables where the relevant information is stored.
For those people who know how to pull info out of the profile information, do you have any suggestions on how to get this info?
I have read that it can be done through $profile while others say $account. I haven't had any luck with either.
The code we are supposed to use in the template.php (in our template of choice) is basically:
$form['signup_form_data']['somefield'] = array(
'#type' => 'textfield',
'#title' => t('somefield),
'#size' => 40, '#maxlength' => 64,
'#required' => TRUE,
);
How can this be used to then pull information from the profile in this format:
$form['signup_form_data']['Name']['#default_value'] = $user->name;
Thanks!