+ Start a Discussion

Richtext fields don't save in Visualforce page

Got a problem where richtext fields don't save on a Visualforce page. They show up just fine in view and edit mode on the VF page. I can put data and pictures in them from the standard UI but when I add anything to the richtext fields on the VF page and click Save those fields aren't saved. Every other field on the page is saved, just not the richtext fields. The page and controller are both on version 19.0 and all development (and testing) is being done on in a dev org, not Eclipse.


Am I doing something wrong here?


Here's the relevant code:


public class contactEditController
  ApexPages.StandardController controller;
  public Contact con;

  public olesContactEditController(ApexPages.StandardController c)
    controller = c;

    // Get the current record.
    this.con = (Contact)controller.getRecord();


  // Override standard save to NOT return a page reference.
  // This lets us close the popup window via javascript.
  public PageReference save()
    return null;

        <apex:pageBlockButtons location="bottom">
          <apex:commandLink action="{!save}" value="Save" oncomplete="closeWin(true);" title="Save changes" />
            <apex:outputLabel for="relationship">Relationship:</apex:outputLabel>
            <apex:inputField id="relationship" value="{!Contact.Relationship__c}" />






In my opinion, you have used  <apex:inputfield> as a rich textfield but <apex:inputfield> don't have any richtext attribute in component. Look in to the sample code given below :


                                          <apex:page controller="cls_richbox">

                                                <apex:form >


                                                                <apex:pageBlock title="RichEditBox">

                                                                                <apex:pageBlockSection title="RichTextEditor" >

                                                                                        <apex:pageBlockSectionItem >

                                                                                                  <apex:inputTextarea value="{!inputValue}" id="theTextarea" richText="true" />




                                                                                  <apex:pageBlockButtons >

                                                                                         <apex:commandButton value="Save" action="{!doSave}" reRender="richrend"/>








                            public class cls_richbox


                                public string inputValue{get;set;}

                                public cls_richbox(){}

                                public void doSave()


                                  system.debug('$$$$$$$$' + inputValue);

                                  Employee__c emp = new Employee__c();

                                 emp.name = 'saurabhbajaj';

                                 emp.testrich__c = inputValue;

                                  insert emp;




Hope this helps.


I tried this instead:


<apex:inputTextArea id="relationship" value="{!Contact.Relationship__c}" richtext="true" rows="10" cols="80" />


and I got a richtext area - cool, didn't know about that - but it continues to not save. I did some experiments and this saves just fine if I remove the richtext="true" attribute. The underlying field is still a richtext field.


Any other ideas? This seems to be a bug in the implementation of the richtext field - I would replace them with regular text fields except the customer requires the ability to insert an image in the rich text field ...









The same is working at my end and in my opinion, you have done some other mistake in your code.


Looks like the rerender attribute is causing the issue. If you remove the rerender arrtribute, it may work.