[support] Add multi-line text to a textarea

Sponge Harkonnen cksponge at gmail.com
Fri Feb 10 18:01:17 UTC 2012


Hey all,

I'm trying to add a default value that has multiple lines to a text area
and am unable to add line breaks. The default value is being built out of
an array with the goal that each entry of the array is on it's own line.
Adding \n, \r\n, or \r only adds the \n,\r\n, or \r as text and not as a
new line. Is there some sort of preprocessing I need to do to the text in
order to get the line breaks to show up in the textarea?

Code:
$codes = variable_get('somevariablename', array());

$display = '';

foreach ($codes AS $key => $value) {
  $display.= $value . "\n";
}

$form['textareatitle'] = array(
  '#title' => 'Title',
  '#type' => 'textarea',
  '#default_value' => $display,
);

Any help or pointing in the right direction would be appreciated. Thanks!
Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20120210/6b2d43b9/attachment.html 


More information about the support mailing list