Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Understanding viewModel
  • I know this might defeat the purpose of using a viewModel but in some cases
    i need to a DB check prior to calling the viewmodel ( access check for example) ..in that DB check I can already get some info i need for my view ( but not all) in such case if i can pass a variable to the viewmodel, it would save me another DB call. is there a way to pass a variable to the viewmodel? if not how do I minimize my DB calls , should i remove the viewmodel altogether?
    thanks
  • After you create the ViewModel, you simply set variables on it like any other view:
    $view = ViewModel::factory('foo');
    $view->bar = 'BAR!!!';
    $view->set('yay', 'YAAAYY');
    
  • Thank you Dan!
    exactly what I was looking for :)

Howdy, Stranger!

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

In this Discussion