Jump to:

3432 Posts in 1025 Topics by 865 members

Template Questions

SilverStripe Forums » Template Questions » problem with RenderWith() function.

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

Page: 1
Go to End
Author Topic: 651 Views
  • Benas
    Avatar
    Community Member
    7 Posts

    problem with RenderWith() function. Link to this post

    Hi,

    what is wrong with my code? I`m getting error: "Fatal error: Call to a member function renderWith() on a non-object in"

    This is my code:

    DropDownMenu.php:

    <?php

    class DropDownMenu extends DataObjectDecorator {
       
       function extraStatics() {
          return array(
             'db' => array (
                'DropDownMenu' => 'Boolean',
             ),
             'has_one' => array(
                
    )
          );
       }
       
       public function updateCMSFields(FieldSet &$fields) {

    $fields->addFieldToTab("Root.Content.Main", new CheckBoxField("DropDownMenu","Drop down menu"), "Content");
          
    }   
       public function dropdownmennu(){
          return $this->parent->renderWith('dropdownmenu');
       }
    }
    class DropDownMenu_Controller extends ContentController {
       function init(){
       
          parent::init();
          Requirements::css("dropdownmenu/css/dropdownmenu.css");   
       }
    }

  • dizzystuff
    Avatar
    Community Member
    93 Posts

    Re: problem with RenderWith() function. Link to this post

    Hi Benas

    I'm pretty sure

    $this->parent->renderWith('dropdownmenu');

    should read

    $this->owner->renderWith('dropdownmenu');

  • Benas
    Avatar
    Community Member
    7 Posts

    Re: problem with RenderWith() function. Link to this post

    It works! Thank you!

    651 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.