statamic-rad-pack / runway

Eloquently manage your database models in Statamic.
https://statamic.com/addons/rad-pack/runway
MIT License
112 stars 47 forks source link

JavaScript error `TypeError: M.collection is undefined` #612

Closed janhenkes closed 3 weeks ago

janhenkes commented 3 weeks ago

Description

When I click on the "Link" button for a BelongsTo relation field, the popover opens, but I don't see the list of selectable entries of the related model. In the console I see the following JavaScript error:

TypeError: M.collection is undefined

The error is thrown in vendor/statamic/cms/resources/js/components/inputs/relationship/Selector.vue on line 425.

When I return to an earlier version (7.6.0) of runway this problem does not exist. I can see in src/Fieldtypes/BaseFieldtype.php that something changed with the response, but I don't fully understand what changed.

After some debugging I found out that this only occurs when 'published' is set to 'true' for the runway resource.

Steps to reproduce

  1. Create two models with a BelongsTo relationship
  2. Define runway resources for the models
  3. Create a belongs_to field in the blueprint
  4. Create a record of model A
  5. Try to link model B in the belongs to field

config/runway.php:

<?php
return [
    'resources' => [
        \App\Models\Scheme::class                => [
            'name'        => 'Schemes',
            'title_field' => 'name',
            'template'    => 'scheme',
            'published'   => true,
        ],
        \App\Models\Round::class                 => [
            'name'        => 'Rounds',
            'title_field' => 'name',
            'template'    => 'round',
            'published'   => true,
        ],
    ],
];

Scheme field in resources/blueprints/vendor/runway/round.yaml:

tabs:
  sidebar:
    display: Sidebar
    sections:
          -
            handle: scheme_id
            field:
              resource: scheme
              create: false
              display: Scheme
              type: belongs_to
              listable: true

Environment

Environment Application Name: ESLHO EQA Portal Laravel Version: 10.48.22 PHP Version: 8.3.10 Composer Version: 2.3.5 Environment: local Debug Mode: ENABLED URL: eslho-eqa-portal.test Maintenance Mode: OFF

Cache Config: NOT CACHED Events: NOT CACHED Routes: NOT CACHED Views: CACHED

Drivers Broadcasting: log Cache: file Database: mysql Logs: stack / single Mail: smtp Queue: sync Session: file

Statamic Addons: 1 Sites: 1 Stache Watcher: Enabled Static Caching: Disabled Version: 5.26.0 PRO

Statamic Addons statamic-rad-pack/runway: 7.9.5

github-actions[bot] commented 3 weeks ago

Released as part of v7.10.1.