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.

Template Questions /

problem with RenderWith() function.


Reply


3 Posts   711 Views

Avatar
Benas

Community Member, 7 Posts

7 April 2012 at 2:37am

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");   
   }
}

Avatar
dizzystuff

Community Member, 93 Posts

8 April 2012 at 2:51am

Hi Benas

I'm pretty sure

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

should read

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

Avatar
Benas

Community Member, 7 Posts

8 April 2012 at 6:20am

Edited: 08/04/2012 6:21am

It works! Thank you! :)