public function get_userfields() { $data = unserialize($this->profile_fields) ?: array(); return $data }
foreach ($comments as $comment) var_dump( $comment->user->get_userfields());
$comments = Model_Comment::find() ->related('user') ->order_by('created_at', 'desc') ->limit(12) ->get(); $view->set('comments', $comments, false);
Harro Verton wrote on Sunday 11th of March 2012:You can not pass serialized data to your view. FuelPHP's security system will escape it, which makes it no longer valid. Either pass it to the view without escaping (not very secure),
Harro Verton wrote on Sunday 11th of March 2012:or use the Type observer in your model to automatically do the serialize/unserialize, and have it always available as an array. See https://github.com/fuel/depot/blob/1.0/develop/fuel/modules/admin/classes/model/user.php as an example of a user model.
Harro Verton wrote on Sunday 11th of March 2012:See https://github.com/fuel/depot/blob/1.0/develop/fuel/modules/admin/classes/model/user.php as an example of a user model.
protected static $_properties = array( 'id', 'username', 'password', 'group', 'email', 'last_login', 'login_hash', 'remember_me', 'profile_fields' => array( 'data_type' => 'serialize', ), 'created_at', 'updated_at' );
It looks like you're new here. If you want to get involved, click one of these buttons!