Jump to:

794 Posts in 409 Topics by 304 members

Widgets

SilverStripe Forums » Widgets » Render form in widget called with renderWith() from Page class

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 593 Views
  • esakrielaart
    Avatar
    Community Member
    56 Posts

    Render form in widget called with renderWith() from Page class Link to this post

    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

    593 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.