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

apex:pageBlockSectionItem align labels within a column

Here's something that would have saved me some time if I had found it by searching. I have a pageBlockSection with two columns, and I wanted to include two fields in one column with a single label applied to both fields, just like the Contact Edit page where the label "First Name" appears before the Salutation and FirstName fields.


Only the label was not aligning with the other labels in the same column, until I tried the following. To my surprise, VF didn't recognize this as more than two child components. Hope it helps someone!


<apex:pageBlockSectionItem >
                  <apex:outputLabel value="First Name"/>
                  <apex:inputField value="{!Contact.Salutation}">
                      <apex:inputField value="{!Contact.FirstName}"/>




Yes, you're right. I usually do this when I have more than two components inside a pageblocksection item.


<apex:pageBlockSectionItem >
                 <apex:outputLabel value="First Name"/>
                 <apex:outputPanel >
                     <apex:inputField value="{!con.Salutation}"/>
                    <apex:inputField value="{!con.FirstName}"/>


Bind them inside some container, so you end up having only two child components for the pageblocksectionItem :)


The above code is working fine ..thanks.:)