Skip to content

[Form] Collection ordering #8987

@trsteel88

Description

@trsteel88

I have a form with a collection of images. The user can re-order the images. I am using Doctrine2's Criteria for sorting the images.

    public function getImages()
    {
        $criteria = Criteria::create()
            ->orderBy(array('rank' => Criteria::ASC, 'id' => Criteria::ASC));

        return $this->images->matching($criteria);
    }

If the form is submitted and contains an error, the images are not loaded in the order submitted by the user. FYI, I am sorting the rank as a hidden field. The user drag/drops which updates the hidden rank in the html.

I am pretty sure this was working correctly when I found it here: #8315

The Criteria class should re-order the collection using logic, rather than a query since the query has already been run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions