[development] Additional user account field

Dayton Perkins perkinsd at chartermi.net
Thu Sep 24 11:28:51 UTC 2009

I am doing a networking site for some one that is targeting college
students. It is important that they have a campus associated with their
account. I need a little advice as to how best to approach this.

I have a database table of campuses that includes a state field. My first
take was to add some JavaScript in the registration form. Users select a
state from a select list, which uses AJAX to populate a div with a list of
links for that state. Choosing a link then in turn gives a visual indication
that a campus has been chosen and populates a hidden input value which was
empty, etc. etc. This was not too tough using jQuery and what have you.

I used something like this:

function campus_validate($form, &$form_state){


            drupal_set_message(t('Please select a state and campus'));

            return false;


      return true;



function user_form_alter(&$form, $form_state, $form_id) {

      if ($form_id == 'user_register') {

            $form['Personal']['campus'] = array(

              '#type' => 'hidden',

              '#default_value' => "",

              '#required' => TRUE        


// the following are not correct, but the idea is I need to validate the
extra fields I am adding. I can muddle through these.

            $form['Personal']['campus']['#element_validate'] =

            // $form['profile_sex']['#element_validate'] =



So I think you can see where I am going with this although it isn't

The next thing I want to do, is I prefer to add a tab for editing the users'
campus. I prefer this to adding to the user/edit form. Once again, I will
need to have a state select that will use AJAX to query and provide a list.
Fortunately, I can probably reuse a lot of the code from the registration
form. Can someone please suggest how to add a tab to /user, and if you have
any suggestions as to making this less labor-intensive, that would be super!

If the whole thing should be tossed, and go with multi-step submissions,
please point me the right way on that.

Thank you so much.



Kindest Regards,

Dayton Perkins

Good News Design

Interactive  Web sites for business

mailto:dayton at goodnewsdesign.com

http://goodnewsdesign.com <http://goodnewsdesign.com/> 

Phone:  616-399-5617

Cell: 616-405-6360

3611 Butternut Drive Lot 40

Holland MI 49424



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.drupal.org/pipermail/development/attachments/20090924/ca3256f1/attachment-0001.htm>

More information about the development mailing list