Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Viewmodel error question
  • I am getting this error from my controller call to a viewmodel: "OutOfBoundsException [ Error ]: ViewModel "View_Abouttwp" could not be found." This is the line in my controller which is flagged in the flow:
    ViewModel::forge('Abouttwp');
    

    This is the viewmodel code in the file at app/classes/view/abouttwp.php
    <?php
    
    /**
     * The abouttwpm view model.
     *
     * @package  app
     * @extends  ViewModel
     */
    class View_Abouttwpm extends ViewModel
    {
     /**
      * Prepare the view data, keeping this in here helps clean up
      * the controller.
      *
      * @return void
      */
     public function view()
     {
      $messages = array('Aw, crap!', 'Bloody Hell!', 'Uh Oh!', 'Nope, not here.', 'Huh?');
      $this->title = $messages[array_rand($messages)];
     }
    }
    
    I've checked the spelling, capitalization and underscores and they seem to match the documentation.
    The files actually exist in the correct (I think) directories and access rights are correct.
    Can anyone suggest where the problem lies?
  • You have an extra 'm' in the classname in the class definition... class View_Abouttwpm extends ViewModel
  • That's embarrassing, thanks. I use both instances with and without the 'm' and the fingers sometimes get confused...<g>

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion