rich (HTML) area never empty

Please report bugs and any annoyances here. Kindly include all possible details: steps to reproduce, expected result, actual result, screenshots, ... etc.
Post Reply
User avatar
baudwalker
Veteran Member
Posts: 188
Joined: 2015-02-03 08:08
Location: Bellingen NSW Australia

rich (HTML) area never empty

Post by baudwalker » 2019-10-27 22:50

Hi all,

I have text feild set as a "Rich (HTML) area". I wish to only show the content of this feild if it is not empty, but as this type of feild always has and entry of "<br>" at a minimum so it is never empty. A text feild set as a "Text area" can be empty.

Is there a way to have am empty "Rich (HTML) area"

Barry

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: rich (HTML) area never empty

Post by pbottcher » 2019-10-28 12:20

Hi,

this is the default behaviour of nicEdit.

Either you edit the nicEdit.js and replace
this.setContent("<br />")
by
this.setContent("")
or you can use

Code: Select all

$j('.nicEdit-main').html('');
to clear the <br> when it is set at the beginning.

For the first option you need to keep in mind that this may be overwritten if you regenerate your project.
The second option may be a little bit more tricky, as you may need to check first if the nicEdit is already present and then check if it contains only the "<br>" and then replace it.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
baudwalker
Veteran Member
Posts: 188
Joined: 2015-02-03 08:08
Location: Bellingen NSW Australia

Re: rich (HTML) area never empty

Post by baudwalker » 2019-10-29 03:47

Great... Thank you

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: rich (HTML) area never empty

Post by jsetzer » 2019-10-29 06:24

Additionally, if you need to remove <br> before saving to have an empty value in the database table, you can do a simple serverside replacement of <br> in hooks/TABLENAME_before_insert() and hooks/TABLENAME_before_update() hook like this:

Code: Select all

// file: hooks/TABLENAME.php

// ...

function TABLENAME_before_insert(&$data, $memberInfo, &$args){
    if ($data['FIELDNAME']=='<br>') $data['FIELDNAME']=null;
    return TRUE;
}

function TABLENAME_before_update(&$data, $memberInfo, &$args){
    if ($data['FIELDNAME']=='<br>') $data['FIELDNAME']=null;
    return TRUE;
}

// ...
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

Post Reply