-
Notifications
You must be signed in to change notification settings - Fork 823
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
relationships that refer to instances of File should default to UploadField in the CMSFields #8482
Comments
It works if you write it like this:
But we should consider making the |
Yeah - the key is that it just works out of the box without having to write your own getCMSFields, just like it does with Varchars, etc... |
That works to the assumption that both |
I've only had a very quick look at this, but I don't think the DBFile model has the ability to alter this behaviour. The fact that it's rendered by a GridField is initiated by Because it's a many many, it defaults to rendering as a GridField. You can adjust this on a per model basis like this: # File: YourDataObject.php
public function scaffoldFormFields($_params = null)
{
$_params['fieldClasses']['GalleryImages'] = UploadField::class;
return parent::scaffoldFormFields($_params);
} It's currently not possible to adjust this globally by the relationship's data model type. I'm not saying it shouldn't be changed to do so, but noting its current limitation. As @kinglozzer noted, implementing support for this in core would require that we don't introduce any coupling - there isn't enough extensibility in this area at the moment, so we'd also need to add some extension points. We may also consider adding a configuration API for relationship model types to default field classes for the form scaffolder - something like: SilverStripe\Forms\FormScaffolder:
default_relationship_field_classes:
many_many:
SilverStripe\Assets\File: SilverStripe\AssetAdmin\Forms\UploadField If we went with the configuration approach then we could easily slot that into asset-admin and have it be safely decoupled. |
This is done as part of silverstripe/.github#262 |
Affected Version
Description
When you add has_many / many_many Images then you get an unworkable gridfield rather than a perfect UploadField when you scaffold the CMS Fields.
The text was updated successfully, but these errors were encountered: