function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jason Reed 63Jason Reed 63 

Display a rich text field after a checkbox is checked in visualforce

Trying to figure out how to display a Rich Tex Field after a checkbox is checked on a Visualforce page.
RbnRbn
Hi Jason,

You can try the below approach.

1) Download the ckeditor standard package from this url https://ckeditor.com/ckeditor-4/download/.
2)Go to Your Name –>Develop –> Static Resources and click ‘New.’ Upload the zip file and call it ‘CkEditor.’
3)Try the below code in your org.I have made use of my custom object api name and custom object field api name. You can change it according to your requirement.
 
<apex:page standardController="Job_Application__c" >
<apex:includescript value="{!URLFOR($Resource.CkEditor,'ckeditor/ckeditor.js')}" />
<script type="text/javascript">
function ReloadCKEditor() {
   for(name in CKEDITOR.instances)
   {
       delete CKEDITOR.instances[name];
   }
   CKEDITOR.replaceAll();
}
</script>

    <apex:form >
        <apex:pageBlock id="thePageBlock">
            <apex:actionRegion >
                <apex:pageBlockSection id="pbs1" title="Information" columns="2"> 
                    <apex:inputField value=" {!Job_Application__c.CheckboxTest__c}">// Here Job application is my custom object and Checbox test is the checkbox 
                        <apex:actionSupport event="onchange" reRender="thePageBlock"  oncomplete="ReloadCkEditor();"/>
                    </apex:inputField>
                     </apex:pageBlockSection>
            </apex:actionRegion>
                <apex:pageBlockSection title="Rich Text Box Section" id="Section" columns="2"  collapsible="false" rendered="{!Job_Application__c.CheckboxTest__c==true}"> 
                          <apex:inputTextarea value="{!Job_Application__c.Test_Richtext__c}"  styleClass="ckeditor" richText="false" />//This is the rich text box area which will be displayed when you check the checkbox
                              </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Below is the output:

User-added image

Let me know if it solves your problem.

Cheeres,
Rabindranath


 
Jason Reed 63Jason Reed 63
Thanks, I am trying to avoid using JavaScript and strictly Salesforce APEX...is there another way?
Raj VakatiRaj Vakati
you can't  able to Rerender RTF after checkbox check ... 

https://salesforce.stackexchange.com/questions/152772/rerender-is-not-currently-supported-with-rich-text-editing-enabled
RbnRbn
Hi Jason,

 The rich text area field will be initialised through JavaScript when the page is loaded, so without the using a script i am afraid if we would be able to achieve this functionality using Apex. Since rerender is not supported for Rich Text fields in Salesforce.

You can try using Flows once and see if you are able to meet the requirement.

Cheers,
rabi