Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle empty list of types #151

Closed
emteknetnz opened this issue Dec 21, 2023 · 3 comments
Closed

Handle empty list of types #151

emteknetnz opened this issue Dec 21, 2023 · 3 comments

Comments

@emteknetnz
Copy link
Member

emteknetnz commented Dec 21, 2023

If there are no allowable types of links to be created the LinkPicker will end up with a fatal error e.g.

[Emergency] Uncaught InvalidArgumentException: "SilverStripe\LinkField\Form\LinkField": Allowed types cannot be empty

This can be forced with LinkField::create('MyLink')->setAllowedTypes([]);, though it's also possible if the CMS user fails canCreate() checks on the allowed link types.

Since the CMS user has no control over this, we should allow and empty list of types and display a UI message on the frontend instead of an empty dropdown

ACs

  • There should be a message should be "Unable to create link"
  • There should not be a fatal PHP error arriving via ajax
  • If develop passes an empty array to setAllowedTypes() there should still be an exception because this is a developer error rather than a bunch of permission checks failing

PR

@GuySartorelli
Copy link
Member

@emteknetnz Please add a link to the PR

@emteknetnz
Copy link
Member Author

Done

@sabina-talipova
Copy link
Contributor

PR was merged. Close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants