You need to sign in to do that
Don't have an account?
Field labels not displaying on visualforce page
Hi,
I'm creating 2 columns on one of our visualforce pages and I am able to seperate the fields into 2 columns but whenever I get this happening the field labels are removed. The visualforce page only shows the actual input text fields but not the labels.
Below is my code on the VF page:
<apex:pageBlockSection columns="2">
<apex:pageblock title="Account Information">
<apex:inputField label="Lead Status" value="{!newLead.Status}" required="true" /> <br> </br>
<apex:inputField label="Fuel Type" value="{!newLead.Fuel_Type__c}" /> <br> </br>
<apex:inputField label="Region" value="{!newLead.Region__c}" /> <br> </br>
<apex:outputField value="{!newLead.RecordTypeId}" /> <br> </br>
</apex:pageblock>
<apex:pageblock title="Account Information 2">
<apex:inputField value="{!newLead.Consumption__c}" /> <br> </br>
<apex:inputField value="{!newLead.Dual_Fuel__c}" /> <br> </br>
<apex:inputField value="{!newLead.Associated_Dual_Fuel_Site__c}" /> <br> </br>
<apex:inputField value="{!newLead.Qualification_Check__c}" /> <br> </br>
</apex:pageBlock>
</apex:pageBlockSection>
Am I doing something wrong here? Does anyone know how I can get the labels to appear?
Any help is much appreciated
Write the code
<apex:pageBlockSection columns="2">
<apex:pageblock title="Account Information">
<apex:pageBlockSection columns="1">
<apex:inputField value="{!newLead.Status}" required="true" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:pageBlockSection>
Thnaks.
All Answers
To Display label you need to define <apex:ouputLabel>. And use following syntax for outputLabel value
{!$ObjectType.ObjectName.fields['FieldName'].label}
Here is the code : If this post solves your problem kindly mark it as solution.
Thanks
Hi Rohit,
Thanks - this shows the field label now.
The only thing is the field label appears above the field input - is there a way in which the label can be placed on the same row as the input field?
1) https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_pageBlockSection.htm
Let us know if this will help you
Thanks
Amit Chaudhary
Write the code
<apex:pageBlockSection columns="2">
<apex:pageblock title="Account Information">
<apex:pageBlockSection columns="1">
<apex:inputField value="{!newLead.Status}" required="true" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:pageBlockSection>
Thnaks.
With this code I can only see input fields but not the labels ,also I have given columns="2" , but fields are being rendered in only one column , can someone tell me where I am wrong ?
<apex:page standardcontroller="account" tabstyle="Branch__c" setup="false" sidebar="false" showheader="true">
<apex:sectionHeader title="Account Edit" subtitle="New Account" />
<apex:form >
<apex:pageblock title="Account edit">
<apex:pageblockbuttons location="both">
<apex:commandbutton value="Edit"/>
<apex:commandbutton value="Save"/>
<apex:commandbutton value="Cancel"/>
</apex:pageblockbuttons>
<apex:pageblocksection title="Account Details " columns="3" collapsible="true"/>
<apex:inputfield label="Name" value="{!account.Name}"/> <br></br>
<apex:inputfield Label="Parent ID" value="{!account.parentid}"/> <br></br>
<apex:inputfield value="{!account.AccountNumber}"/> <br></br>
<apex:inputfield value="{!account.Type}"/> <br></br>
<apex:inputfield value="{!account.Industry}"/> <br></br>
<apex:inputfield value="{!account.AnnualRevenue}"/><br></br>
<apex:inputfield value="{!account.Phone}"/> <br></br>
<apex:inputfield value="{!account.Fax}"/> <br> </br>
<apex:inputfield value="{!account.Rating}"/> <br></br>
<apex:inputfield value="{!account.Website}"/> <br></br>
<apex:inputfield value="{!account.Ownership}"/> <br></br>
<apex:pageblocksection title="Related cases " collapsible="true"/>
<apex:pageblocksection title="Related Contacts " collapsible="true"/>
<apex:pageblocksection title="Related Opportunities" collapsible="true"/>
</apex:pageblock>
</apex:form>
</apex:page>