How to Create a Textarea Field

The Form::textarea() method works similar to the Form::input() method except that it allows for a fourth parameter to determine if existing HTML entities are encoded or not, the default is to convert everything.

  echo Form::textarea('name');
  <textarea name="name"></textarea>

Add the second parameter to declare a value

  echo Form::textarea('name', 'This is my body');
  <textarea name="name">This is my body</textarea>

The third parameter accepts an array of attributes

  echo Form::textarea('name', 'This is my body', array('disabled'=>FALSE));
  <textarea name="name" disabled="1">This is my body</textarea>

If the body of your textarea includes existing HTML entities then set the fourth parameter to FALSE to avoid double encoding.

  // &amp; will be double encoded
  echo Form::textarea('name', 'You &amp; Me', NULL, TRUE);
  <textarea name="name">You &amp;amp; Me</textarea>
  // &amp; will NOT be double encoded
  echo Form::textarea('name', 'You &amp; Me', NULL, FALSE);
  <textarea name="name">You &amp; Me</textarea>
how_to_create_a_textarea_field.txt · Last modified: 2009/10/18 00:40 by kerkness