Print array in field value I have created a custom form in form field following code is there.

 $form['display_result'] = array(
   '#title' =&gt; 'Result' ,
   '#type' =&gt; 'textarea',
   '#value' =&gt; !empty($dval) ? $dval : null,
   '#default values' =&gt; '',
 )


Problem is $dval is array which includes following code:

    stdClass Object
(
    [to] =&gt; Tove
    [from] =&gt; Jani
    [heading] =&gt; Reminder
    [body] =&gt; Don't forget me this weekend!
)


I am getting following warning:


  Warning: htmlspecialchars() expects parameter 1 to be string, object given in check_plain() (line 1571 of /var/www/html/D7/includes/bootstrap.inc)
It's recommended to use #default_value instead of #value.

You have to use property of object instead of whole object. For example $dval-&gt;body.

$form['display_result'] = array(
    '#title' =&gt; t('Result'),
    '#type' =&gt; 'textarea',
    '#default_value' =&gt; !empty($dval-&gt;body) ? $dval-&gt;body : '',
  );