Medium Editor <br> tags

Wondering if there is any work around to Medium Editor fields that have not been used on form submissions sending stray <br> tag in the form submission.

I would not mind stopping them before they insert to database, or getting rid of them later on client side when retrieving the results back.

The reason I am having a problem with this is that the stray <br> tag means that i can not add a condition saying if it’s empty do not display it, because it is never empty. I can not use a replace filter for it either because then real <br> tags are replaced when on the rare occasion the user has entered real data in that field.

Hello Paul,
Try using the stripTags formatter to remove the html and then trim any white-space. If the string is then empty do not put anything in the database otherwise insert the html.

{{ $_POST.input.stripTags().trim() != "" ? $_POST.input : "" }}
1 Like

Ahhh, brilliant I knew you would have some idea, haha, you should see the scary things i tried that looked nothing like that. Will let you know if that solves it Teo, thank you

1 Like

Ok so it works client side on a condition with

<div is="dmx-if" dmx-bind:condition="scViewAccommodationDetail.data.queryAccomDetail.accom_inner_opinion.stripTags().trim() != '' ? scViewAccommodationDetail.data.queryAccomDetail.accom_inner_opinion : ''" id="condit_our_opinion">
	<p class="text-justify ac-colourD ac-fontC4w cms-added-styles-accom-opinion" dmx-html="scViewAccommodationDetail.data.queryAccomDetail.accom_inner_opinion"></p>
</div>

AND works on the Insert step, which is actually a database update step with this in the value field.

{{$_POST.act_inner_review.stripTags().trim() != "" ? $_POST.act_inner_review : "" }}

Thank You a thousand times over.

Why would you need this on the clientside? I am not sure i understand what are you trying to achieve with the condition expression there.

You can just use something like

dmx-show="scViewAccommodationDetail.data.queryAccomDetail.accom_inner_opinion"

as an expression to check if the database field has a value or not - if it returns a value, the dmx-show will show your element on the page.

Yes thats how I would normally do it Teo, it was only because I could not get it to have no data initially that i started fiddling around trying to get rid of the extra 30 pixels of white space it was bringing into my design, but yes normally I would do it the way you are suggesting.

Don’t suppose off the top of your head you know a way in MySQL to find all <p><br></p> instances in multiple tables and columns to replace with nothing. I can do it a column at a time and a table at a time, but is there anyway to do them all?

Probably you can create a database dump (.sql file) then do search and replace and then import the dump back in your DB.

1 Like

Thats exactly how I normally do it, but I was too embarrassed to say because I thought there was far smarter commands to do it, glad to see my grep txt editor I revert to whenever I have SQL issues is a semi normal thing to do. Lol

Haha - maybe there are, but i find this to be the fastest way to do it :slight_smile:

1 Like

I doubt it, if you dont know them, then they don’t exist, I love my txt editor anyway, haha

1 Like