Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
Unescaping whole ORM object.
quizer
June 2013
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
Harro
June 2013
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.
quizer
June 2013
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?
Harro
June 2013
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?
quizer
June 2013
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.
Harro
June 2013
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.
quizer
June 2013
Okay. Thanks for your help. Problem solved.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
June 2013
quizer
June 2013