$attributes Block attributes. * @since 0.0.2 */ public function __construct( $attributes ) { $this->set_properties( $attributes ); $this->set_input_label( __( 'Textarea', 'sureforms' ) ); $this->set_error_msg( $attributes, 'srfm_textarea_block_required_text' ); $this->slug = 'textarea'; $this->is_richtext = $attributes['isRichText'] ?? false; // Min-length only applies to plain textareas; the rich-text submission contains HTML markup. $this->min_length = $this->is_richtext ? '' : ( $attributes['minLength'] ?? '' ); $this->max_length = $attributes['maxLength'] ?? ''; // Misconfiguration guard — if min exceeds max, drop min so the form stays submittable. // The editor already warns the form-builder when this happens. if ( '' !== $this->min_length && '' !== $this->max_length && (int) $this->min_length > (int) $this->max_length ) { $this->min_length = ''; } $this->rows = $attributes['rows'] ?? ''; $this->read_only = ! empty( trim( $this->default ) ) && $attributes['readOnly']; // html attributes. $this->min_length_attr = $this->min_length ? ' data-minlength="' . esc_attr( $this->min_length ) . '" ' : ''; $this->max_length_attr = $this->max_length ? ' maxLength="' . esc_attr( $this->max_length ) . '" ' : ''; $this->rows_attr = $this->rows ? ' rows="' . esc_attr( $this->rows ) . '" ' : ''; $this->max_length_html = '' !== $this->max_length ? '0/' . $this->max_length : ''; $this->random_id = wp_rand( 1000, 9999 ); $this->set_unique_slug(); $this->set_field_name( $this->unique_slug ); $this->set_markup_properties( $this->input_label . '-' . $this->random_id, ! empty( $this->min_length ) ); $this->set_aria_described_by(); $this->set_label_as_placeholder( $this->input_label ); } /** * Render the sureforms textarea classic styling * * @since 0.0.2 * @return string|bool */ public function markup() { $classes = [ 'srfm-block-single', 'srfm-block', 'srfm-' . $this->slug . '-block', 'srf-' . $this->slug . '-' . $this->block_id . '-block', $this->block_width, $this->class_name, $this->conditional_class, $this->is_richtext ? 'srfm-richtext' : '', $this->read_only ? 'srfm-read-only' : '', ]; $classes = Helper::join_strings( $classes ); $random_id = $this->unique_slug . '-' . $this->random_id; ob_start(); ?>
label_markup ); ?> help_markup ); ?>
is_richtext ) { ?>
is_richtext && ( '' !== $this->min_length || '' !== $this->max_length ) ) { $display_limit = '' !== $this->max_length ? $this->max_length : $this->min_length; ?>
min_length ) { ?> data-counter-min="min_length ); ?>" aria-live="polite" >0/
error_msg_markup ); ?>