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