Add documentation for limiting allowed widgets

An addendum to clarify that yes, you can lock a WidgetArea down to certain widgets, and how to accomplish this.
This commit is contained in:
Garion Herman 2016-12-20 23:44:49 +13:00 committed by GitHub
parent 0986537be7
commit 04dbb41125

View File

@ -156,3 +156,14 @@ An example widget is below:
<a href="$Link" rel="lightbox" title="$Title"><img src="$Image" alt="$Title" /></a> <a href="$Link" rel="lightbox" title="$Title"><img src="$Image" alt="$Title" /></a>
<% end_control %> <% end_control %>
## Limiting Allowed Widgets for a Pagetype
You can lock down a particular `WidgetAreaEditor` to only allow adding certain widgets by passing them as a second parameter.
**GreatPage.php**
:::php
$fields->addFieldToTab(
'Root.Widgets',
new WidgetAreaEditor('PhenomenalWidgetArea', ['ParticularlyEpicWidget', 'LessGreatWidget'])
);