Textarea line breaks not saved to DB
-
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 ??
- The topic ‘Textarea line breaks not saved to DB’ is closed to new replies.