Relation manager is able to handle reorder

Hi,

If I use Relation manager, is this able to handle reorder behaviour like drag&drop

Thank you,
Zs

Yes it can.

Seeing your screenshot, let’s say you have two models :

  • Supporting (table : author_plugin_supportings)
  • SupportingDetail (table: author_plugin_supportingdetails)
  1. Make sure in author_plugin_supportingdetails, you have two fields; supporting_id and sort_order.

  2. In your model SupportingDetail, add inside the class:

    use \October\Rain\Database\Traits\Sortable;
    
  3. In your relation_config.yaml of your Supporting controller, update it and add the structure section:

    supportingdetails:
        label: ...
        view:
            list: ...
            toolbarButtons: ...
            recordsPerPage: ...
        manage:
            form: ...
        structure:
            showReorder: true
            showTree: false
    

Thank you for your help. @apinard .

Can we do filtering in relation controller?

@ngyzsolt Add the filter into the view configuration.

supportingdetails:
    label: ...
    view:
        list: ...
        toolbarButtons: ...
        recordsPerPage: ...
        filter: $/authorname/plugin/models/supportingdetail/scopes.yaml
    manage:
        form: ...
    structure:
        showReorder: true
        showTree: false

and in $/authorname/plugin/models/supportingdetail/scopes.yaml, something like:

scopes:
    category:
        label: Category
        modelClass: Acme\Blog\Models\Category
        conditions: category_id in (:value)
        nameFrom: name

Unfortunatelly does not render the filter, in relation controller. And I do not got any errors.

You can render filters in relation controller, i’ve done it in many projects.

Download the test plugin and find what you need.

php artisan plugin:install October.Test --from=https://github.com/octobercms/test-plugin

Thank you for you help. It is working! :slight_smile:

1 Like