• Resolved seejlim

    (@seejlim)


    Is it possible to preserve the line breaks in the textarea fields without enabling the rich text editor? I set up integrations with Slack and Google Sheets and the line breaks are not showing up on either.

    I’ve checked the support forums and this one gets close, but there is no solution posted.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @seejlim,

    Could you please check whether the following code helps?

    <?php
    /**
     * Plugin Name: [Forminator Pro] - Sanitize textarea field
     * Plugin URI: https://premium.wpmudev.org/
     * Description: Preserves new lines (\n) and other whitespace (as of 1.12.1.1)
     * Author: Alessandro Kaounas @ WPMUDEV
     * Author URI: https://premium.wpmudev.org/
     * Task: SLS-180
     * License: GPLv2 or later
    */
    
    add_filter( 'forminator_field_text_sanitize', function( $data, $field, $original_data ){
        
        $data = $original_data;
        $editor_type   = Forminator_Field::get_property( 'editor-type', $field, false, 'bool' );
        
        // Sanitize
        if ( true === $editor_type ) {
            $data = wp_kses_post( $data );
        } else {
            $data = forminator_sanitize_textarea( $data );
        }
    
        return $data;
    
    }, 10, 3);

    You can add the above code as mu-plugins. Please check this link on how to implement the above code as a mu-plugins:
    https://premium.wpmudev.org/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Kind Regards,
    Nithin

    I think this should be a default behaviour in future versions (without need for muplugin)

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @mrbleuu

    I hope you are doing well.

    I can see we do have plans to extend it as a native function, however, we don’t have an estimated time yet.

    Best Regards
    Patrick Freitas

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Textarea line breaks without rich text editor’ is closed to new replies.