SilverStripe\Widgets\Model\WidgetController
Optional controller for every widget which has its own logic, e.g. in forms.
It always handles a single widget, usually passed in as a database
identifier through the controller URL. Needs to be constructed as a nested
controller within a .
## Forms
You can add forms like in any other SilverStripe controller. If you need
access to the widget from within a form, you can use
`$this->controller->getWidget()` inside the form logic.
Note: Widget controllers currently only work on objects,
because the logic is implemented in .
Copy this logic and the URL rules to enable it for other controllers.
Synopsis
class WidgetController
extends Controller
{
- // members
- protected Widget $widget;
- private static array $allowed_actions = ;
- // methods
- public void __construct()
- public string Link()
- public Controller getParentController()
- public Widget getWidget()
- public string Content()
- public string WidgetHolder()
- public string editablesegment()
Hierarchy
Extends
- SilverStripe\Control\Controller
Members
Methods
public
- __construct()
- Content() — Overloaded from {@link Widget->Content()} to allow for controller / form linking.
- Link()
- WidgetHolder() — Overloaded from {@link Widget->WidgetHolder()} to allow for controller/ form linking.
- editablesegment() — Uses the `WidgetEditor.ss` template and {@link Widget->editablesegment()} to render a administrator-view of the widget. It is assumed that this view contains form elements which are submitted and saved through {@link WidgetAreaEditor} within the CMS interface.
- getParentController() — Cycles up the controller stack until it finds a non-widget controller This is needed becauseController::currreturns the widget controller, which means anyLinkfunction turns into endless loop.
- getWidget()