It seems that the weight of fields is managed by cck and not by the form api. This could be a problem, if you add or alter some form arrays (e.g. with the fieldgroup module).
The problem is, that a form array is built for every field ($form[$field['field_name']] = array('#tree' => TRUE)) and within this array another array with the field itseld with the weight attribute is set. It would make more sense to set the weight attribute within the $form[$field['field_name']] array.

CommentFileSizeAuthor
#2 cck_weight_4-7.txt6.29 KBmh86
#1 cck_weight.patch7.25 KBmh86

Comments

mh86’s picture

Version: 4.7.x-1.x-dev » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new7.25 KB

I wrote a patch, which would fix the described problem above. I added the weight attribute to the $form[$field['field_name']] array to the cck field types.

mh86’s picture

StatusFileSize
new6.29 KB

here the patch for 4.7.

fago’s picture

works fine.

the patch is important to have the weights correctly working with the fieldgroup module.
so let's use the form api weights for what they exist.. further this patch would be needed for any sorted hook_form_alter extensions.

so +1 for this

whereisian’s picture

big +1 - patch seems to work correctly. solved my issue with fieldgroups also.

cheers!

karens’s picture

Wouldn't it make more sense for content.module to do this? Content.module controls the widget that sets the weight, so it should also manage the setting of the weight in the form. That also eliminates the need for redundant code in all the field modules.

I have no time to create a patch right now, unfortunately.

eliza411’s picture

When I installed the fieldgroup module, I thought that the input form and default output would honor those groups and weights. I also thought the "manage fields" tab would, too, although that's less problematic since the users never see it.

Instead, the default output and the "manage fields" seem to honor only the weight.

I tried installing the patch here, but I don't see any change in the behavior . . . was the patch supposed to make it so that the default output order would be sorted by groups then weights within the groups or was that wishful thinking.

fago’s picture

the fieldgroup module does nothing regarding output, it's about forms only. but that's another topic and has nothing to do with this issue.

RobRoy’s picture

Any progress on a non-redundant patch for content.module? This patch works, but I agree that this code is better suited in a central location. I'm pretty weak on CCK atm, but may try next week if no one else gets to this.

karens’s picture

Status: Needs review » Fixed

In the process of creating the 5.0 port I found a very simple non-redundant way to get the content module to insert the field weight in the form array (see http://drupal.org/node/91030) so I am committing this change to the 4.7 version. This means no changes to the individual field modules will be required.

Anonymous’s picture

Status: Fixed » Closed (fixed)