|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @since 3.0 |
|
5
|
|
|
*/ |
|
6
|
|
|
class FrmFieldTextarea extends FrmFieldType { |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @var string |
|
10
|
|
|
* @since 3.0 |
|
11
|
|
|
*/ |
|
12
|
|
|
protected $type = 'textarea'; |
|
13
|
|
|
|
|
14
|
|
|
protected $is_tall = true; |
|
15
|
|
|
|
|
16
|
|
|
protected function field_settings_for_type() { |
|
17
|
|
|
return array( |
|
18
|
|
|
'size' => true, |
|
19
|
|
|
'clear_on_focus' => true, |
|
20
|
|
|
); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
protected function extra_field_opts() { |
|
24
|
|
|
return array( |
|
25
|
|
|
'max' => '5', |
|
26
|
|
|
); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param string $name |
|
31
|
|
|
*/ |
|
32
|
|
|
public function show_on_form_builder( $name = '' ) { |
|
33
|
|
|
$size = FrmField::get_option( $this->field, 'size' ); |
|
34
|
|
|
$size_html = $size ? ' style="width:' . esc_attr( $size . ( is_numeric( $size ) ? 'px' : '' ) ) . '";' : ''; |
|
35
|
|
|
|
|
36
|
|
|
$max = FrmField::get_option( $this->field, 'max' ); |
|
37
|
|
|
$default_value = FrmAppHelper::esc_textarea( force_balance_tags( $this->get_field_column('default_value') ) ); |
|
38
|
|
|
|
|
39
|
|
|
echo '<textarea name="' . esc_attr( $this->html_name( $name ) ) . '" ' . |
|
40
|
|
|
$size_html . ' rows="' . esc_attr( $max ) . '" ' . |
|
|
|
|
|
|
41
|
|
|
'id="' . esc_attr( $this->html_id() ) . '" class="dyn_default_value">' . |
|
42
|
|
|
$default_value . |
|
|
|
|
|
|
43
|
|
|
'</textarea>'; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
protected function prepare_display_value( $value, $atts ) { |
|
47
|
|
|
FrmFieldsHelper::run_wpautop( $atts, $value ); |
|
48
|
|
|
|
|
49
|
|
|
return $value; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param array $args |
|
54
|
|
|
* @param array $shortcode_atts |
|
55
|
|
|
* |
|
56
|
|
|
* @return string |
|
57
|
|
|
*/ |
|
58
|
|
|
public function front_field_input( $args, $shortcode_atts ) { |
|
59
|
|
|
$input_html = $this->get_field_input_html_hook( $this->field ); |
|
60
|
|
|
$this->add_aria_description( $args, $input_html ); |
|
61
|
|
|
$rows = ( $this->field['max'] ) ? 'rows="' . esc_attr( $this->field['max'] ) . '" ' : ''; |
|
62
|
|
|
|
|
63
|
|
|
return '<textarea name="' . esc_attr( $args['field_name'] ) . '" id="' . esc_attr( $args['html_id'] ) . '" ' . |
|
64
|
|
|
$rows . $input_html . '>' . |
|
65
|
|
|
FrmAppHelper::esc_textarea( $this->field['value'] ) . |
|
66
|
|
|
'</textarea>'; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|