Thanks for the module. I like it.

This feels like a stupid question... I added the CCK address field, but how do I change the order that the address items appear on the node edit page? By default when I edit the node I see:

  • Country:
  • State / Province:
  • City:
  • Street:
  • Additional:
  • Postal code:

This seems like an un-intuitive order to me.

When I save and view the node then the fields appear in a normal order.

Comments

AlexisWilke’s picture

Now that I have added sub-modules, I can see this problem too, quite a bit.

I think it would be really cool if we could have the same system as for menus & modules (a weight system where -50 is first and +50 is last...) I do not know how easy/hard it would be to add to your existing table of radio buttons. But that's where I would put it!

Thank you.
Alexis Wilke

P.S. this is also a problem without the CCK extension that is.

AlexisWilke’s picture

As a temporary fix, I actually went in the code and added a weight to all the fields. That forces the order automatically (by the Drupal FAPI, Form internal stuff).

Here is the phone entry, see the extra 'weight' field at the end. Make sure to add a comma on the previous line if you do not have one yet.

      'phone' => array(
        'type'        => 'varchar',
        'length'      => 16,
        'description' => t('Phone numbers, like cellphone, home, office'),
        'display'     => ADDRESSES_FIELD_NONE,
        'title'       => t('Phone'),
        'theme'       => array(
          'phone'         => t('Phone number.'),
        ),
        'token'       => 'addresses_general',
	'weight'      => -9
      ),

At this time, ordering the fields in this way is useful only for the setup. In other words, you may not care much. The weight does not carry over to the other forms. For that you need to add a '#weight' in the second part. I suggest the same weight in both places.

    // Telephone number
    if ($fields['phone'] == ADDRESSES_FIELD_HIDDEN) {
      $form['phone'] = array(
        '#type'           => 'hidden',
        '#value'          => isset($values['phone']) ? $values['phone'] : '',
      );
    }
    elseif (!empty($fields['phone'])) {
      $form['phone'] = array(
        '#type'           => 'textfield',
        '#title'          => t('Phone'),
        '#default_value'  => isset($values['phone']) ? $values['phone'] : '',
        '#size'           => 16,
        '#maxlength'      => 75,
        '#attributes'     => NULL,
        '#required'       => ($fields['phone'] == ADDRESSES_FIELD_REQUIRED),
	'#weight'         => -9
      );
    }

Obviously, this is not too good since you need to edit all the files to fix/change the weights... but until a good old fix, it should do for you.

Thank you.
Alexis

mikepadiernos’s picture

I looked within the source and I found out that the output of the form goes by the order within the module itself. I moved it around following the order I liked and it came out properly.

picciuto’s picture

Can you point me where within the code i can rearrange this? Thanks.

AlexisWilke’s picture

picciuto,

There are several places.

Edit the addresses/addresses.module file to see the main list of fields.

There are such fields in all sub-modules though.

Thank you.
Alexis

picciuto’s picture

Thanks Alexis!

pancho’s picture

Version: 6.x-1.0-alpha2 » 6.x-1.0-alpha3
Category: support » bug

It would be cool if it was configurable just as the displayed address formats are. I might take a look at this the next days.

pancho’s picture

Title: Order of CCK address items » Edit form: Configurable address item order
brmassa’s picture

Status: Active » Fixed

Guys,

hi! A similar issue was created on http://drupal.org/node/290579, so i will keep the communication there ok? I will work on the solution right now.

regards,

massa

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mrtoner’s picture

Category: bug » feature
Status: Closed (fixed) » Closed (duplicate)