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

DOC Document new tab order and form scaffolder changes #549

Merged

Conversation

Comment on lines 52 to 55
use SilverStripe\Forms\CheckboxSetField;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\TextareaField;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically unrelated but these were missing.

To fully customise your form fields, start with an empty FieldList.
To define the form fields yourself without using scaffolding, use the `tabsOnly` option in [`DataObject.scaffold_cmsfields_settings`](api:SilverStripe\ORM\DataObject->scaffold_cmsfields_settings). See [scaffolding options](#scaffolding-options) for details.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new best practice - it's always best to call the parent method when you can, and now you can.

Comment on lines -80 to -81
> [!TIP]
> It is good practice to invoke the `updateCMSFields()` extension hook afterward, so that extensions in modules can apply their functionality to your field list.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer relevant since we're calling the parent method.

- [Define scaffolded form fields for relations to `DataObject` models](#scaffolded-relation-formfields)
- [`FormField` scaffolding for `DataObject` models](#scaffolding)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the existing form field scaffolding item as a sub-item in a new section, so now there's an overall formfield scaffolding section with both the existing docs and the new docs inside it.


#### Define scaffolded form fields for relations {#scaffolding-relation-formfields}

Most `DataObject` classes will rely on some amount of automatic scaffolding of form fields in their `getCMSFields()` implementations. However, it's common for modules to provide a specialised form field which is intended to always be used with a specific `DataObject` class. In those cases, even though you always want to use that form field with that class, you have to copy some boilerplate code from the module's documentation to set it up.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only change to this line (see removal of the same line above) was removing the API link since we're linking to that in the parent heading section instead.

en/02_Developer_Guides/00_Model/11_Scaffolding.md Outdated Show resolved Hide resolved

|option|description|
|---|---|
|`tabbed`|Use tabs for the scaffolded fields. All database fields and `has_one` fields will be in a "Root.Main" tab. Fields representing `has_many` and `many_many` relations will either be in "Root.Main" or in "Root.`<relationname>`" tabs.|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fields representing has_many and many_many relations will either be in "Root.Main" or in "Root.<relationname>" tabs.

Shouldn't these always be in the "Root.<relationname>" tab? Seems like that's the point of the option?

Copy link
Member Author

@GuySartorelli GuySartorelli Aug 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tab they're in is determined by the scaffoldFormFieldForHasMany() and scaffoldFormFieldForManyMany() methods which can opt to not include the fields in their own tabs.

This option allows tabs to be used, but it doesn't force it.


#### Define scaffolded form fields for relations {#scaffolding-relation-formfields}

Most `DataObject` classes will rely on some amount of automatic scaffolding of form fields in their `getCMSFields()` implementations. However, it's common for modules to provide a specialised form field which is intended to always be used with a specific `DataObject` class. In those cases, even though you always want to use that form field with that class, you have to copy some boilerplate code from the module's documentation to set it up.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth mentioning that SiteTree subclasses would be auto-scaffolded, I know it's documented elsewhere though it's such a common use case I think it's worth mentioning here so people don't get confused why things aren't not working

Copy link
Member Author

@GuySartorelli GuySartorelli Aug 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is for CMS 5, where SiteTree formfields are never scaffolded.
SiteTree scaffolding is happening in CMS 6.

@GuySartorelli
Copy link
Member Author

Added docs for restrictRelations (see silverstripe/silverstripe-framework#11328 (comment))

@GuySartorelli GuySartorelli force-pushed the pulls/5/scaffolding-and-taborder branch 2 times, most recently from 66fdd7f to 7290280 Compare August 12, 2024 00:20
@GuySartorelli GuySartorelli force-pushed the pulls/5/scaffolding-and-taborder branch from 7290280 to f0dcf5b Compare August 12, 2024 00:44
@emteknetnz emteknetnz merged commit 966283e into silverstripe:5 Aug 12, 2024
3 checks passed
@emteknetnz emteknetnz deleted the pulls/5/scaffolding-and-taborder branch August 12, 2024 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants