Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
About ViewModels...
  • Did we understand that's for manage data from DB with it ?

    I'm little bit confuse about the purpose of this class and how to use it ?

    I know that's optionnal, but what advantage did you expected about ?
  • HarroHarro
    Accepted Answer
    It is best practice that you don't put any logic in your view files, other then maybe simple if's or loops.

    A Viewmodel (or Presenter in more general OO terms) is a way to abstract away any view specific logic from the view, without having to put it in the controller. That would be bad practice too, as the logic is related to the view, and not the controller.

    When I speak about View logic you can think about stuff like converting object structures to simple array's you can loop over, fetching array data to populate drop-downs, translations, conversions, formatting using sprintf()'s, etc.

Howdy, Stranger!

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

In this Discussion