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
Amber090Amber090 

Put more fields on the right

Hi- I have a VF page with multiple fields and we need to move more to the right.  What is the code to block out where a field should be to make another field stay to the right column?  Does that make sense?
KaranrajKaranraj
Include 'columns=2' in the pageblocksection VF tag. Check the below sample code
 
<apex:page standardController="Account">
    <apex:form>
        <apex:pageBlock title="My Content" mode="edit">
            <apex:pageBlockButtons>
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="My Content Section" columns="2">
                <apex:inputField value="{!account.name}"/>
                <apex:inputField value="{!account.site}"/>
                <apex:inputField value="{!account.type}"/>
                <apex:inputField value="{!account.accountNumber}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
Amber090Amber090
Thank you- What if we want the Type & Account Number fields both under the Site field? What block code would be inbetween those inputfield codes to push the last 2 fields to the right column?
KaranrajKaranraj
Use <apex:pageBlockSectionItem/>. If no content is specified, the column is rendered as an empty space. Try the below code
<apex:page standardController="Account">
    <apex:form >
        <apex:pageBlock title="My Content" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="My Content Section" columns="2">
                <apex:inputField value="{!account.name}"/>
                <apex:inputField value="{!account.site}" />
                <apex:pageBlockSectionItem />
                <apex:inputField value="{!account.type}"/>
                  <apex:pageBlockSectionItem />
                <apex:inputField value="{!account.accountNumber}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>



 
Amber090Amber090
Worked perfectly! Thank you!