Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
a profile_fields' problem
  • Hey guys, I don't understand how to use the informations into the profile_fields, my field is as following
    I tried $user->profile_fields but it displays 'a'.
    Also I have insert this value by using the create_user method and the following value
    array('department' => Input::post('department')) Thanks in advance
  • The docs say: If you want to access the user object directly (for example because you query the table outside Auth), you need to unserialize it yourself, or (if you use ORM) use the type observer to convert it automatically when you read the data from the database.
  • Ok solved I first had problem to unserialize, then I found that topic
    Here is my final code
    $profile_fields = unserialize(html_entity_decode($user->profile_fields, ENT_QUOTES));
    echo $profile_fields; Thanks Harro
  • Why are you doing an html_entity_decode() ? Is this code in your view?
  • Yes I have created an object $user with Model_Users::find('all') and sent it to my view. But I changed and added the following in my controller: View::set_global('profile_fields', unserialize($user->profile_fields));
  • If you're using an ORM model, use the Typing observer.
    protected static $_observers = array(
      'Orm\\Observer_Typing' => array('before_save', 'after_save', 'after_load')
    Then define your profile field property as
    protected static $_properties = array(
      'profile_fields' => array(
       'data_type' => 'serialize',
    and the ORM will unserialize it automatically on load, and serialize it on save.

Howdy, Stranger!

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

In this Discussion