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
PawelWozniakPawelWozniak 

How to render Label, field and button in one line?

Here is a requrement from client: 

 

 

In one line I need: field name, filed itself, and button.

This must be fitted inside one column of: <apex:pageBlockSection columns="2" >

 

So I came up with this:

 

<apex:pageBlockSectionItem >
    <apex:inputField label="Activation Counter" id="activationCounter" value="{!object.field__c}"/>
    <apex:commandButton value="Reset"/>
</apex:pageBlockSectionItem>

 which results in missing label:

 

So I wanted to add field label like this:

 

<apex:pageBlockSectionItem >
    <apex:outputLabel value="Activation Counter" for="activationCounter"/>
    <apex:inputField label="Activation Counter" id="activationCounter" value="{!object.field__c}"/>
    <apex:commandButton value="Reset"/>
</apex:pageBlockSectionItem>

 an now getting error:

 

Error: <apex:pageBlockSectionItem> may have no more than 2 child components

 

Is there a way to get it working together?

Best Answer chosen by Admin (Salesforce Developers) 
SeAlVaSeAlVa

Try the following

<apex:pageBlockSectionItem >
    <apex:outputLabel value="Activation Counter" for="activationCounter"/>
    <apex:outputPanel layout="block">
        <apex:inputField label="Activation Counter" id="activationCounter" value="{!object.field__c}"/>
        <apex:commandButton value="Reset"/>
    </apex:outputPanel>
</apex:pageBlockSectionItem>

 This way, pageblocksectionitem has two children and you have your three components.

Regards

All Answers

SeAlVaSeAlVa

Try the following

<apex:pageBlockSectionItem >
    <apex:outputLabel value="Activation Counter" for="activationCounter"/>
    <apex:outputPanel layout="block">
        <apex:inputField label="Activation Counter" id="activationCounter" value="{!object.field__c}"/>
        <apex:commandButton value="Reset"/>
    </apex:outputPanel>
</apex:pageBlockSectionItem>

 This way, pageblocksectionitem has two children and you have your three components.

Regards

This was selected as the best answer
PawelWozniakPawelWozniak

Nice workaround. Thank you.

GeniuanGeniuan
Thank you @[SeAlVa], excelent answer, so  clear.
SF DEVSF DEV
Thanks @SeAIVa. its worked for me.