woensdag 22 januari 2020

Set Rich Text Editor Item type readonly with HTML

We have made a simple form to send an email.
So we use an item of the type Rich Text Editor to markup the body of an email with HTML support.



When the mail has been sent, the user can open the email again but in read only mode.

The issue we have now is that the content of the RTE item is shown as plain text and the HTML has been stripped.


That was confusing since users couldn't see their generated signature any more or special HTML markup they used to compose their emails.


After reading this blog from Carsten and noticing here there is a read only property in the CK Editor config the solution wasn't hard to find :

In the advanced options of the RTE item in the apex page designer we find a field called "Javascript Initialization Code". When we enter some conditional javascript in there that checks the value of an item we can enable the readonly option :



function ( pOptions) {
    if ($v('P106_MAIL_STATUS_CODE') == 'SEND') { 
        pOptions.readOnly = true;
    }
    return pOptions;
}

PS : A lot of options for the editor can be altered this way. 

When a user goes to a sent email he sees the Rich Text Editor but with all buttons and input disabled (except for the print button ... cool):



Grtz,
Fred

Set Rich Text Editor Item type readonly with HTML

We have made a simple form to send an email. So we use an item of the type Rich Text Editor to markup the body of an email with HTML suppor...