This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

I'm having issues using the RainLab Builder plugin. I have my fields set so they can be reordered and my controller has reordering capabilities, but when I click the reorder button when accessing the custom plugin I built using RainLab Bulder, I get an error page with the folliwing:

The model must implement the NestedTree or Sortable traits. /Users/jacobbuller/Desktop/Sites/bullernotbuellercms/modules/backend/Behaviors/ReorderController.php line 225

Anyone know how to fix this issue?

The documentation shows how to implement this behaviour in your model: https://octobercms.com/docs/backend/reorder

Great thanks! I'll try it out and post here if I hit any snags.

So I added use \October\Rain\Database\Traits\Sortable; to my plugin model, but now I get the following issue. Any reason why this might be happening with RainLab Builder? My database doesn't have

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sort_order' in 'order clause' (SQL: select * from jcbbuller_projects_ order by sort_order asc)

jcbbuller52235 said: So I added use \October\Rain\Database\Traits\Sortable; to my plugin model, but now I get the following issue. Any reason why this might be happening with RainLab Builder? My database doesn't have SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sort_order' in 'order clause' (SQL: select * from jcbbuller_projects_ order by sort_order asc)

Add the sort_order field to your model's database table.

Sounds simple enough. Do I need to add integers into the sort_order field in the database or do they prepopulate automatically?

UPDATE: Got it to work. Created a sort_order integer field, set the default value to null, and everything seems to be working! So if you have this issue, do that. Thanks for the help Eoler and Flynsarmy

Last updated

jcbbuller52235 said: UPDATE: Got it to work. Created a sort_order integer field, set the default value to null, and everything seems to be working!

This will probably do for existing records, but to ensure valid data (inserts, etc.) you can also add the following event handler to the model class:

    public function beforeValidate()
    {
        if (empty($this->sort_order))
        {
            $this->sort_order = static::max('sort_order') + 1;
        }
    }

1-8 of 8

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.