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
                    )
                )
            )
1
  • Haha. "How to get rich..." made me smile
    – Matt P
    Apr 11, 2017 at 20:23

2 Answers 2

3

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

1
  • This is more precise response.
    – Gfra54
    Feb 14, 2020 at 7:55
1

Got It through ->

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

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.