Skip to content

MultiLinkField on SiteConfig returns "Failed to load link(s)" on Save #385

@TheSceneman

Description

@TheSceneman

Module version(s) affected

4.2.3

Description

When a MultiLinkField is added to SiteConfig via extension and updateCMSFields() it says "Failed to load link(s)" after the SiteConfig is saved. The links are saved, it is the retrieval of the updated list of links which is failing. See screenshot below from Network tab of Chrome dev tools. Subsequent requests add more square brackets:

Image

How to reproduce

Add extension to siteconfig

SilverStripe\SiteConfig\SiteConfig:
  extensions:
    - App\Extensions\SiteConfigExtension
<?php

namespace App\Extensions;

use SilverStripe\Core\Extension;
use SilverStripe\Forms\FieldList;
use SilverStripe\LinkField\Form\MultiLinkField;
use SilverStripe\LinkField\Models\Link;

class SiteConfigExtension extends Extension
{

    private static array $has_many = [
        'ConfigLinks' => Link::class . '.Owner',
    ];

    private static array $owns = [
        'ConfigLinks',
    ];

    public function updateCMSFields(FieldList $fields)
    {
        $fields->addFieldToTab('Root.Main', MultiLinkField::create('ConfigLinks'));
    }
    
}

Then navigate to siteconfig via {yourdomain}/admin/settings. Add a new link of any type via the Configlinks field.
Click save, you should see the error message. If you refresh the page you will see the links have been saved OK.

Possible Solution

I rolled the silverstripe/linkfield version back to 4.0.0 and this fixed the issue, so the breaking change has been introduced between 4.0.0 and 4.2.3

Validations

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)

PRs

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions