Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Widgets /

Discuss SilverStripe Widgets.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Render form in widget called with renderWith() from Page class


Reply


678 Views

Avatar
esakrielaart

Community Member, 58 Posts

29 September 2012 at 9:41pm

Hi all,

I hope the title says it all, but my problem is as follows. A page contains several different widgets, which I use for pagination, so one widgetblock should represent one page content. I currently read the correct item using

// Inside Page.php
$widget = $this->WidgetArea()->Widgets("Sort = {$page}")->first();

Where $page is the page number (ie, 0, 1, ...)

Now, I render this widget with the proper template using:

// Inside same method in Page.php
$content = $widget->renderWith(array($class, 'Widget'), array());
return new ArrayData(array(
'Response' => $content
));

Where $class is the (verified) classname of the widget.

So far so good, except that this will not render any forms on the template of the widget, as I think, because calling $WidgetForm (defined on WidgetClassName_Controller) is actually looking for a method WidgetForm() on Page.php. How can I tell SilverStripe to use WidgetClassName_Controller instead?

Friendly regards,
Maurice