Twill: Browser positions don't save

Created on 20 Jan 2019  路  4Comments  路  Source: area17/twill

Hi,

I have a Project module with a browser where you can assign Projecttag modules.

It all works fine except the position of the Projecttags doesn't get saved- they appear to just save in alphabetical order. The Projecttag module does have HasPosition, and there are values being saved to the "position" field in the project_projecttag table, but again it seems to be based on alphabetical order rather than their position in the browser.

Any help?

Thanks!

bug

Most helpful comment

@ifox I figured out what was going on. Not really a bug just needs some more setup.

public function pages()
    {
        return $this->belongsToMany(\App\Models\Page::class)
            ->withPivot(['position'])
            ->orderBy('pivot_position','asc');
    }

Need to make sure you include the pivot table position column and then order by that column.

All 4 comments

Hi Seb,

really sorry for the delay here, notifications overflow...!

Congratulations again for launching your Twill based site :)

I'm not able to reproduce this but I'm probably missing something that I know that is not in the docs, something like that. I'll dig more and get back to you.

Is there a fix for this?

@ifox I figured out what was going on. Not really a bug just needs some more setup.

public function pages()
    {
        return $this->belongsToMany(\App\Models\Page::class)
            ->withPivot(['position'])
            ->orderBy('pivot_position','asc');
    }

Need to make sure you include the pivot table position column and then order by that column.

Fixed, finally! @rmenner you rock!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

newvladimirov picture newvladimirov  路  3Comments

newvladimirov picture newvladimirov  路  5Comments

stevanpavlovic picture stevanpavlovic  路  7Comments

brammittendorff picture brammittendorff  路  6Comments

noxify picture noxify  路  4Comments