Newer Version Available

This content describes an older version of this product. View Latest

Best Practices for Page Block Components

Adding More than Two Child Components to <apex:pageBlockSectionItem>
An <apex:pageBlockSectionItem> component can only have up to two child components. Sometimes, though, you want to add an extra child component. For example, you may want to add an asterisk before an <apex:outputLabel> and still display the associated input text field. You can do this by wrapping the asterisk and output label in an <apex:outputPanel> component, as follows:

For this page to display account data, the ID of a valid account record must be specified as a query parameter in the URL for the page. For example:

1https://Salesforce_instance/apex/myPage?id=001D000000IRosz

Note

1swfobject.registerObject("clippy.codeblock-1", "9");<!-- Page: -->
2<apex:page standardController="Account">
3    <apex:form >
4        <apex:pageBlock title="My Content" mode="edit">
5            <apex:pageBlockSection title="My Content Section" columns="2">
6                <apex:pageBlockSectionItem >
7                    <apex:outputPanel>
8                        <apex:outputText>*</apex:outputText>
9                        <apex:outputLabel value="Account Name" for="account__name"/>
10                    </apex:outputPanel>
11                    <apex:inputText value="{!account.name}" id="account__name"/> 
12                </apex:pageBlockSectionItem>
13            </apex:pageBlockSection>
14        </apex:pageBlock>
15    </apex:form>
16</apex:page>
17