1 <?php
2
3 /**
4 * Multi-line text field.
5 *
6 * @package Fieldmanager_Field
7 */
8 class Fieldmanager_TextArea extends Fieldmanager_Field {
9
10 /**
11 * @var string
12 * Override field_class
13 */
14 public $field_class = 'text';
15
16 /**
17 * Construct default attributes; 50x10 textarea
18 * @param string $label
19 * @param array $options
20 */
21 public function __construct( $label = '', $options = array() ) {
22 $this->attributes = array(
23 'cols' => '50',
24 'rows' => '10'
25 );
26
27 // Sanitize the textarea to preserve newlines. Could be overriden.
28 $this->sanitize = 'fm_sanitize_textarea';
29
30 parent::__construct( $label, $options );
31 }
32
33 /**
34 * Form element
35 * @param mixed $value
36 * @return string HTML
37 */
38 public function form_element( $value = '' ) {
39 return sprintf(
40 '<textarea class="fm-element" name="%s" id="%s" %s >%s</textarea>',
41 esc_attr( $this->get_form_name() ),
42 esc_attr( $this->get_element_id() ),
43 $this->get_element_attributes(),
44 esc_textarea( $value )
45 );
46 }
47
48 }