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
rich (HTML) area never empty
- baudwalker
- Veteran Member
- Posts: 188
- Joined: 2015-02-03 08:08
- Location: Bellingen NSW Australia
Re: rich (HTML) area never empty
Hi,
this is the default behaviour of nicEdit.
Either you edit the nicEdit.js and replace
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.
this is the default behaviour of nicEdit.
Either you edit the nicEdit.js and replace
bythis.setContent("<br />")
or you can usethis.setContent("")
Code: Select all
$j('.nicEdit-main').html('');
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.
- baudwalker
- Veteran Member
- Posts: 188
- Joined: 2015-02-03 08:08
- Location: Bellingen NSW Australia
Re: rich (HTML) area never empty
Great... Thank you
Re: rich (HTML) area never empty
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
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<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 readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools