I have created CCK fields for the Bio module. I want these fields to show up on the registration form. I am able to do so on the User Biographies configuration page [admin/user/bio]. I check all the fields that I want on the registration form. I am using field groups for groupings such as mailing address and interests.

They all appear on the form registration form but they are in the wrong order. I am wondering if the grouping has something to do with it because groupings do not show up on the registration form at all.

#7 issue_234404.patch2.55 KBjscheel
#4 issue_234404.patch2.53 KBjscheel
Members fund testing for the Drupal project. Drupal Association Learn more


capellic’s picture

For anybody else having this problem, I got around Bio's issue by implementing a module to utilize hook_form_alter. If the idea of creating a module scares you, go to tutorial and you'll get a good idea of what it takes:


Creating a module only requires two files - a .info and a .module file. Both files must be in the same directory which should be in your sites modules folder.


name = GBC Hook Form Alter
description = Enables the adjustment to forms before they are displayed through overrides.
package = "GBC Impact Custom Modules"
version = "n/a"
project = "gbc_hook_form_alter"


function gbc_hook_form_alter_form_alter($form_id, &$form){
    // Edit user registration form - this was added to get around Bio's inablity
    // to add fields to the registration form in an order than made sense.
    switch ($form_id) {
        case 'user_register':		
            $form['field_bio_postal_code']['#weight'] = 0.0175;
            $form['field_bio_country']['#weight'] = 0.0176;
            $form['field_bio_disease_focus']['#weight'] = 1;
            $form['field_regions_cck_taxonomy']['#weight'] = 2;
            $form['field_bio_interests']['#weight'] = 3;
            $form['field_bio_interests_other']['#weight'] = 4;
            $form['field_bio_interests_networking']['#weight'] = 5;

jerdavis’s picture

Status: Active » Postponed (maintainer needs more info)

I'm just starting to dig into this, so I have absolutely no idea how difficult it would be - but it seems like one solution to this ordering issue would be to group (stick/shove) all of the fields for the associated content type being used by Bio into one field set, and weight that field set appropriately on the user registration page, respecting any subsets and weighting for the bio content type within that fieldset. In theory, this sounds easier and cleaner than trying to jam all of the bio content type's fields in and around the registration page's existing fields.

If this is doable, or even makes sense - let me know, I'll see what I can do about writing a patch for it.

Roman S’s picture

This is due to the fact that Bio does not correctly transfer the fields' weights when putting them on the registration form. The following line needs to be added to bio_form_alter:

        // Get the form field and add it to the form.
        $cck_field = $function('prepare form values', $node, $field, $node_field);
        $cck_field = $function('form', $node, $field, $node_field);
        $cck_field[$field['field_name']]['#weight'] = $field['widget']['weight']; // THIS IS THE NEW LINE
        $form = array_merge($form, $cck_field);

This is similar to what the _content_widget_invoke function does in content.module.

Until the fix is in the build, I'm using the following code in mymodule_form_alter to avoid hacking the Bio module:

      // Set proper weights for CCK fields
      $cck_fields = _bio_get_fields();
      foreach ($cck_fields as $field_name => $field) { 
        $form[$field_name]['#weight'] = $field['widget']['weight']; 
jscheel’s picture

Status: Postponed (maintainer needs more info) » Needs review
2.53 KB

I have attached a patch that will fix the two issues here:

  1. fields are not sorted properly
  2. field groups do not appear on the registration page

Thanks for the idea everyone! Please test and let me know if this works for you. This patch was created from Bio 5.x-1.2.

capellic’s picture

Awesome! Thanks for doing this!!!!

davedelong’s picture

the patch worked great for me!

jscheel’s picture

2.55 KB

Found a small problem with my earlier patch: empty fieldsets were not being unset. New patch is attached.

bomarmonk’s picture

Was this fixed already in the development version for 5.x? I see something about form alter and field groups in CVS for March 2008. I am wondering if it's better to patch the official release or go with the development version.