Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Unescaping whole ORM object.
  • How can I unescape whole ORM object?

    If I have: 

    $view->content->set('event_title', $event->title, false);

    print $event_title; in the view works fine.

    But if I want to pass object itselft:

    $view->content->set('event', $event, false);

    print $event->title; is escaped and shows html tags as plain text.

    Thanks
  • You pass it with 'false' as third argument, so the View class will not encode the entire object. So something else must be modifying it.
  • I think it has something to do with before() function in my controller. I use it to initialize View object with:

    global $view;
    $view = View::forge('layout');

    Where I set header / footer views and then use other function's (action_index) etc. to set content view

    It colud be a reason? How can I prevent it? 
  • global?

    It looks like you should swich to the template controller, and use your layout view as the template.

    Are you accessing $event in the content view itself, or are you passing it on to other views?
  • I found what caused this problem but I have no idea why. 

    Event is:
    $event = Model_Event::find('all');

    but before I assigned it to 'events' in View I've set global variable:

    $view->set_global('persons', Model_Person::find('all', array('related' => array('events'))), false);

    Changing it to $view->content->set('persons', Model_Person::find('all', array('related' => array('events'))), false);

    Helped. 

    Could you explain me how setting global variable influenced on escaping characters in other Model?

    Thanks.
  • HarroHarro
    Accepted Answer
    You're passing objects, and objects are always passed by reference in PHP.

    In this case, every variable containing an Event object with a specific primary key will point to the same object. So if one is modified, so are all others.
  • Okay. Thanks for your help. Problem solved.

Howdy, Stranger!

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

In this Discussion