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
R_ShriR_Shri 

hide fields using CSS

I am trying to hide Stage field of opportunity from visualforce page but I am not able to achieve the task.
If I am using style="display:none" nothing is happening and if I am using rendered="false” I am getting error as “The inline edit-enabled dependent picklist 'Lost Reasons' requires its controlling field 'Stage' to be present on the page.” Please help me regarding this ASAP.

I have used the below code. Please let me know if I am missing out something.


<apex:page standardController="Opportunity" docType="html-5.0" id="TheOppPage" tabStyle="Opportunity" showChat="false">
    <apex:form >
        <apex:pageBlock mode="maindetail"  id="thePageBlockDetail1" rendered="{!opportunity.StageName = 'Closed Won' || opportunity.StageName = 'Closed Lost'}">
          
            <!-- All Buttons are defined here-->
            <apex:pageBlockButtons >
                <apex:commandButton action="{!edit}" id="editButton" value="Edit" style="display:none"/>
                <apex:commandButton action="{!save}" id="saveButton" value="Save" style="display:none"/>
                <apex:commandButton action="{!delete}" id="deleteButton" value="Delete" style="display:none"/>
                <apex:commandButton action="{!cancel}" id="cancelButton" value="Cancel" style="display:none" />
            </apex:pageBlockButtons>
          
            <!--Main details of this opportunity are defined here. -->
          
            <apex:pageBlockSection id="thePageBlockSectionDetail1">
                <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton, deleteButton" event="ondblclick"
                    changedStyleClass="myBoldClass" resetFunction="resetInlineEdit" />
                  
                <apex:outputField value="{!opportunity.StageName}" style="display:none"/>
                <apex:outputField value="{!opportunity.Won_Reasons__c}" rendered="{!opportunity.StageName = 'Closed Won'}"/>
                <apex:outputField value="{!opportunity.Lost_Reasons__c}" rendered="{!opportunity.StageName = 'Closed Lost'}"/>
                <apex:outputField value="{!opportunity.customfield1__c}" rendered="{!opportunity.StageName = 'Closed Lost'}"/><br/>
                <apex:outputField value="{!opportunity.customfield2__c}" rendered="{!opportunity.StageName = 'Closed Lost'}"/>    
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>


Thanks in advance!
:)

Regards,
R_Shri
Best Answer chosen by R_Shri
R_ShriR_Shri
Hi,

I achieved the task of Hiding the fields by putting the fields in output panel and hiding that output panel
as,
<apex:outputPanel style="display:none">
                    <apex:outputField value="{!opportunity.StageName}"/>
</apex:outputPanel>

All Answers

R_ShriR_Shri
I'm asking mainly for <apex:outputField value="{!opportunity.StageName}" style="display:none"/>
srinu_SFDCsrinu_SFDC
Hey Shri, Did you try this?
<apex:outputField value="{!opportunity.StageName}" html-style="display:none"/>

Regards,
Srinu
R_ShriR_Shri
Hi Srinu,

Ya I got Error: Cannot override attribute 'style' on component <apex:outputField> if I use html-style="display:none"
R_ShriR_Shri
I am using this VF page as inline vf on Opportunity Layout.
So can I remove/hide Stage from Opportunity layout and display on this inline page only (In doing this I am getting an error as This field must be displayed on the page layout and cannot be removed)
R_ShriR_Shri
Hi,

I achieved the task of Hiding the fields by putting the fields in output panel and hiding that output panel
as,
<apex:outputPanel style="display:none">
                    <apex:outputField value="{!opportunity.StageName}"/>
</apex:outputPanel>

This was selected as the best answer