Jump to:

5542 Posts in 1739 Topics by 1225 members

Customising the CMS

SilverStripe Forums » Customising the CMS » $this->request->getVar() error in controller

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

Page: 1
Go to End
Author Topic: 2014 Views
  • nekranox
    Avatar
    Community Member
    31 Posts

    $this->request->getVar() error in controller Link to this post

    Hey guys,

    This looks like something really simple but I just can't figure it out.

    Front-end loads fine, dev/build works fine but when I try to go to admin I get:

    Fatal error: Call to a member function getVar() on a non-object in /mysite/code/Page.php on line 23

    Here's the offending function in Page.php:

       function BigFont() {
          $BigFont = $this->request->getVar('bigfont');
          if($BigFont == 'true') {
             return true;
          } else {
             return false;
          }
       }

    So it looks like I'm not accessing getVar properly. Strangely, it works on the front end of the site!

    Any ideas?

  • rob.s
    Avatar
    Community Member
    78 Posts

    Re: $this->request->getVar() error in controller Link to this post

    Hi,

    are you using ->getVar() in your Page class or Page_Controller class?

    If it's in Page class, try

    Controller::curr()->getRequest()->getVar()

    If in Page_Controller, try

    $this->getRequest()->getVar()

    Greetings,
    Rob

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