Multiple Value Field Collection ordering doesn't work

Created on 18 February 2012, almost 13 years ago
Updated 26 February 2024, 9 months ago

I have a field collection with the number set to Unlimited such that I can "Add More" of them while editing. The weights seem to be totally ignored in how they are displayed when using this module. The weights are saved just fine (I can see on the edit page where the ordering is correct) and other display methods (e.g. Table, Embedded) also display the fields in the correct order. On the other hand, this module ignores the weights and displays the field collections strictly in the order they were created. I'm not sure if there's some setting in the View I'm using that would allow for this to work based on the weights. I tried a variety of sorting options in the view but nothing worked so far.

🐛 Bug report
Status

Closed: works as designed

Component

Code

Created by

🇺🇸United States Juryiel

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States Eric At NRD

    I could not get #7 to work right for my use case. However, an alternate method using hook_views_post_execute() DID work for me:
    https://www.drupal.org/project/field_collection_views/issues/2075593#com...

    I post this here only in case others ran into circumstances where #7 did not work.

  • 🇮🇷Iran mr.hadimollaei

    Hello
    After searching and checking the experiences of others, unfortunately, I did not reach my desired result
    So I created this command that returns the delta value:

    function get_field_collection_delta($item_id,$table,$field){
    $query = "SELECT delta FROM $table WHERE $field = $item_id";
    $delta = db_query($query)->fetchCol();
    return $delta;
    }

    Then I created a sort using PHP Views module and wrote the following in it:

    $delta1 = get_field_collection_delta($row1->item_id,'field_data_field_art_files_collection','field_art_files_collection_value');
    $delta2 = get_field_collection_delta($row2->item_id,'field_data_field_art_files_collection','field_art_files_collection_value');
    return $delta1 > $delta2;

Production build 0.71.5 2024