Find your content:

Search form

You are here

Strange behavior of , field label is not coming up

 
Share

I have noticed one strange thing about apex:pageBlockSectionItem that if i put a inputField or selectList under pageBlockSectionItem its label gets disappear. I don't know why is this happening? Can anybody explain this.

         <apex:pageBlockSectionItem >
              <apex:outputLabel value="Expiration Date (Mo/Yr)"></apex:outputLabel>
              <apex:pageBlockSectionItem >
              <apex:selectList value="{!expDate}" size="1">
                 <apex:selectOptions value="{!dates}"/>
              </apex:selectList> 
         <apex:pageBlockSectionItem >

I have find out one work around of this by putting up a outputLabel block just before inputField as shown in above example. can anybody explain the best way to get rid of this problem?


Attribution to: Pramod Kumar

Possible Suggestion/Solution #1

This is not a bug or problem. It works exactly as designed. Here is a piece of official salesforce doc:

Note that if you include an <apex:outputField> or an <apex:inputField> component in an <apex:pageBlockSectionItem>, these components do not display with their label or custom help text

To "workaround" this case if using an <apex:inputField> just use no pageBlockSectionItem and the label will be rendered automatically:

<apex:pageBlockSection>
    <apex:inputField value="{!someObj.val__c}" />
</apex:pageBlockSection>

In your case i would use this example:

<apex:pageBlockSectionItem >
   <apex:outputLabel value="Expiration Date (Mo/Yr)"/>
   <apex:selectList value="{!expDate}" size="1">
       <apex:selectOptions value="{!dates}"/>
   </apex:selectList> 
</apex:pageBlockSectionItem>

Attribution to: Sergej Utko
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/5464

My Block Status

My Block Content