2

I have a 'details' rich text field in my User section. How can i get it in my plugin controller in an array. I tried getting it by

 $userInfo[] = array(
  'username' => $user->name,
  'details' => $user->details,
)

I get an array like this

        Array
        (
        [0] => Array
            (
                [username] => Username
                [details] => Craft\RichTextData Object
                    (
                        [_pages:Craft\RichTextData:private] => 
                        [_rawContent:Craft\RichTextData:private] => Lorem Ipsum is a dummy text
                        [content:protected] => Lorem Ipsum is a dummy text
                        [charset:protected] => UTF-8
                    )
                )
            )
  • Haha. "How to get rich..." made me smile – Matt P Apr 11 '17 at 20:23
3

I'd be inclined to use the public methods for this. $user->detail->getRawContent(); or $user->detail->getParsedContent(); etc.

| improve this answer | |
  • This is more precise response. – Gfra54 Feb 14 at 7:55
1

Got It through ->

$userInfo[] = array(
  'username' => $user->name,
  'details' =>  (string) $user->details,
)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.