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
Peter CowenPeter Cowen 

displaying a field once a checkbox is set to true

I have added the below on visualforce page and added to a page layout but it does not display properly. Can you have a look and let me know what is wrong with the code or do I need to write a full visualforce page with the fields.

<apex:page standardController="Service_Request__c" showHeader="true"> <apex:pageBlock > apex:inputText value="{!Service_Request__c.Useful_SQL__c}" rendered="{!(Service_Request__c.Is_this_useful__c == true)}"/> </apex:pageBlock> </apex:page>
Best Answer chosen by Peter Cowen
Bryan JamesBryan James

<apex:page standardController="Service_Request__c" showHeader="true">
    <apex:pageBlock >
        <apex:form><!--Input fields need to be placed inside of apex:form tags-->
           <!--you forgot the the opening tag for this inputText field.--> <apex:inputText value="{!Service_Request__c.Useful_SQL__c}" rendered="{!Service_Request__c.Is_this_useful__c}"/><!-- since this is using a boolean field all you have to do is enter it since it will always only be true or false-->
        </apex:form>
    </apex:pageBlock>
</apex:page>

hope this helps somewhat

All Answers

Bryan JamesBryan James

<apex:page standardController="Service_Request__c" showHeader="true">
    <apex:pageBlock >
        <apex:form><!--Input fields need to be placed inside of apex:form tags-->
           <!--you forgot the the opening tag for this inputText field.--> <apex:inputText value="{!Service_Request__c.Useful_SQL__c}" rendered="{!Service_Request__c.Is_this_useful__c}"/><!-- since this is using a boolean field all you have to do is enter it since it will always only be true or false-->
        </apex:form>
    </apex:pageBlock>
</apex:page>

hope this helps somewhat
This was selected as the best answer
Peter CowenPeter Cowen
Thank you that has fixed that. How do I now get the text entered into that box to save? I have used apex:inputtextarea but when I enter anything it does not remain in that field
Bryan JamesBryan James
You can just use the standard save button from salesforce for this. Just add:
<apex:commandButton value="Save" action="{!save}"/>
after the input field inside the <apex:form> tags.
Peter CowenPeter Cowen
I have done the below visualforce page that has been added into a normal page layout. The inputfield appears but if I enter a value it does not save but if i add the field it relates to on the view and populate it text appears in the visualforce page. How do I get it to save when entering into the visualforce field. 

<apex:page standardController="Service_Request__c" showHeader="true">
public string 
<apex:pageBlock >
<apex:pageBlocksection >
<apex:form >
<apex:outputText value="Enter the useful SQL in the text field provided below" />
  <apex:inputField value="{!Service_Request__c.Useful_SQL__c}" rendered="{!(Service_Request__c.Is_this_useful__c == true)}"/>
  <apex:commandButton action="{!save}" value="Save" />
  </apex:form>
  </apex:pageBlocksection>
  </apex:pageBlock>
</apex:page>

When using the command button it displays the same page in the visualforce page 
Bryan JamesBryan James
Hey Peter can you do me a favor and explain exactly what it is that you are trying to accomplish? That way I can give you the best answer possible. Thanks.
Peter CowenPeter Cowen
I am after a field that only appears when a checkbox is ticked so I have created a visual force page to do this and added this to a standard page layout. I need to be able to save the contents of the text area. Currently if I enter anything in the visual force page text area it does not save. If I enter something in the referenced field it appears in the text area
Bryan JamesBryan James
Is it that you want to be able to use the save button on the page and not the save button on the visualforce page?  
Peter CowenPeter Cowen
Yes if possible at the minute it only gives you edit on the page itself adding the save to the visual force just adds another page inside the visual force page