silverstripe / silverstripe-framework

Silverstripe Framework, the MVC framework that powers Silverstripe CMS
https://www.silverstripe.org
BSD 3-Clause "New" or "Revised" License
720 stars 820 forks source link

Allow individual DataObject to scaffold a FormField that should be used to managed them #11234

Closed maxime-rainville closed 1 month ago

maxime-rainville commented 1 month ago

Description

DBField can scaffold form field to manage what should be used to managed them. e.g. https://github.com/silverstripe/silverstripe-framework/blob/4429a4999dfd1fdfb29a3b910519c389ae8749d7/src/ORM/FieldType/DBMoney.php#L184-L188

HasOne relation use the DBForeignKey to scaffold their field which builds a SearchableDropdownField for most DataObject. It also has a bit of hard coded logic for File.

https://github.com/silverstripe/silverstripe-framework/blob/4429a4999dfd1fdfb29a3b910519c389ae8749d7/src/ORM/FieldType/DBForeignKey.php#L57-L86

They are many scenarios where SearchableDropdownField is not the best form field to use for a specific DataObject. e.g.: Link, SiteTree, Taxanomie Tags.

I'm thinking it would be trivial to update DBForeignKey::scaffoldFormField() to call a matching scaffoldFormField on singleton to retrieve its form field:

Additional context or points of discussion

Related issues

GuySartorelli commented 1 month ago

Is this a duplicate of https://github.com/silverstripe/silverstripe-framework/issues/11079?

GuySartorelli commented 1 month ago

@maxime-rainville If this is the same as #11079 (and I'm 90% sure it is), it can be done in a minor release - in fact that issue is in the 5.3 milestone already.

maxime-rainville commented 1 month ago

Closed as duplicate.