Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Cannot pass ORM object to a view for some reason
  • What's up fuelphp! First of all i'd like to say that i think this framework simply kicks-ass. As a former codeigniter developer I absolutely love FuelPHP and it's features. So a major thanks for everyone involved in creating this awesome framework, you made my life a lot easier. There is however a little problem that I can't seem to figure out: I have a controller in which I request some data from my "Character" model ( Which uses ORM ) and when I pass the data from this model to my view I get the following error:
    RuntimeException [ Error ]: Object class "Orm\Query" could not be converted to string or sanitized as ArrayAcces. Whitelist it in security.whitelisted_classes in app/config/config.php to allow it to be passed unchecked.

    This is the code from my controller:
    $data = array(
    'character' => Model_Character::find( Session::get('charid') )
    ); $this->template->condition = View::forge('game/character', $data); $this->template->title = 'Game > Welcome';

    And this is the code from my view:
    <div id='first-name'><?php echo $character->name; ?></div>

    I think this code is pretty straight-forward, but I'm obviously doing something wrong. Does anyone know how to do this correctly? Thanks in advance!
    Nick Update: I've figured it out! Just needed to add a ->get_one() call after my find() method. Topic may be deleted!
  • Thanks for replying. FuelPHP is a very nice framework but quite hard to figure out reading only the documentation. Thanks again!
  • Two things important to understand here: 1. You need to execute a query as you figured out (either get_one() or get()), an unexecuted query isn't what you want.
    2. Data passed to the View gets encoded, which was impossible for the unexecuted query object but will be done on the model instance - Read more in the docs

Howdy, Stranger!

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

In this Discussion