- Issue created by @aman_lnwebworks
- Assigned to j. ayen green
- Status changed to Fixed
11 months ago 2:06pm 27 December 2023 - 🇺🇸United States j. ayen green
Thanks for the catch! While your patch addresses null being returned, it also would prevent any scheme from being returned were any selected.
Where Drupal directs the user to check the boxes for the schemes that should be allowed, and says that if none are selected all will be allowed, it turns out that this is a promise to the user that needs to be fulfilled by the coder...it's not automatic. I had thought all values would be returned.
What I'm doing to fix this is that if null is returned from the field settings, I call the field item plugin to get the list of schemes and return that list instead of null.
The code changes are:
- Change the method in the field item to being public static
- Add a use statement in the field widget identifying the field item class
- Change the return from getSchemes() to be
return $def->getSetting('allowed_schemes') ?? UrlItem::getSchemes();
The results is that when no schemes are selected in the field settings, all are returned by getSchemes() and the resulting description under the text box is given as:
Enter a URL. Allowed schemes are: http://, https://, ftp://, mailto://, sftp://, ssh://, tel://.
You can pull the dev branch to get this change.
- Status changed to Fixed
11 months ago 2:19pm 27 December 2023