Support » Plugin: Forminator - Contact Form, Payment Form & Custom Form Builder » Textarea line breaks not saved to DB

  • Resolved matlino

    (@matlino)


    When a user inserts line breaks into Textarea field, these are not preserved in DB. I retrieve data from DB using forminator API and present it on the frontend. But the line breaks are not there anymore. This makes the text hard to read.

    Interestingly, in the email notification, the line breaks of Textarea value are preserved. So I tried to find some workaround and reinsert the linebreaks myself before the data are saved to DB. I found out that in hook ‘forminator_replace_custom_form_data’ are two parameters with textarea value – $entry and $field_data. In $entry there are no line breaks but $field_data contains the line breaks in textarea value! So this value is probably used in the email notification. I am no sure but I guess this hook is executing after the data were already saved to DB, right? Then It is a mystery for me how can be the linebreaks present there in $field_data when they are not present in DB?

    I guess, the hook which should be used to edit data before they are saved to DB is this one: ‘forminator_custom_form_submit_before_set_fields’. Problem is that there is only $field_data_array, which does not contain the line breaks.

    So I didn’t found any workaround to this issue :(. It would be great if you could preserve the line breaks in textarea field value so the content can be presented later correctly. Also if there is any workaround to this using e.g. using some other hook to reinsert the linebreaks, let me please know. Thank you 🙂

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @matlino

    I hope you are doing well.

    I made a test but it seems the break lines are also removed on the emails when I submitted a form, I got the inline message.

    We pinged the plugin developers to check if we have any filter that you can use, we will update once hearing back from the developer.

    Best Regards
    Patrick Freitas

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @matlino

    We were able to replicate it and we will include an update on the plugin side for this.

    For now, can you make a full backup of your website,

    Edit the file:

    library/fields/textarea.php

    Replace the:

    $data = forminator_sanitize_field( $data );

    To:

    $data = forminator_sanitize_textarea( $data );

    Let us know the result you got,
    Best Regards
    Patrick Freitas

    Thread Starter matlino

    (@matlino)

    Hi @wpmudevsupport12,
    I uploaded images with the result I get after the changes you proposed:
    https://imgur.com/a/9doSkRN

    As seen in html code picture, it is now returning break lines. But, for some reason it is still not displaying on the page correctly. To be able to display break lines I need to do this:

    
    $rows = explode("\n", $entry->meta_data['textarea-1']['value']);
      foreach ($rows as $row) {
        echo '<p>' . $row . '</p>';
      }
    
    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @matlino

    Thank you for the update, and sorry for the delay on this.

    I pinged our developers to check this too.

    We will keep you posted once hearing back from the developer.

    Best Regards
    Patrick Freitas

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @matlino

    Could you please try this code instead of the loop?

    echo wpautop( $entry->meta_data['textarea-1']['value'] );

    Best Regards
    Patrick Freitas

    Thread Starter matlino

    (@matlino)

    Hi @wpmudevsupport12
    this works like a charm. The text break lines are displayed exactly how they were entered into the field.

    Thank you!

    Tomas

    Thread Starter matlino

    (@matlino)

    Hi @wpmudevsupport12,
    this bug suddenly starts happening again. I was wondering how is it possible and then I realized, I updated the plugin. So you probably didn’t include it in an update. I am just notifying you here in case it was forgotten.

    Tomas

    Plugin Support Predrag – WPMU DEV Support

    (@wpmudev-support1)

    Hi Tomas,

    Thanks for the heads up, I can’t say for sure what happened with this specific report but I’ve pinged our devs and QA to get back on this and check it out further.

    Cheers,
    Predrag

    Thread Starter matlino

    (@matlino)

    Hi @wpmudev-support1 ,
    unfortunately, the fix was not implemented in v. 1.14.8.1.

    Tomas

    Plugin Support Kasia – WPMU DEV Support

    (@wpmudev-support2)

    Hello @matlino ,

    I’m afraid it wasn’t. I checked it with developers and it looks like it’s still in development.
    I’m sorry about the inconvenience.

    kind regards,
    Kasia

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.