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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Widgets /

Discuss SilverStripe Widgets.

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

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


Go to End


1866 Views

Avatar
esakrielaart

Community Member, 59 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