2

I have a pageBlockSection with some inputFields in my VF page:

<apex:pageBlockSection title="Installation" > 
    <apex:inputField label="Label-1" value="..." />
    <apex:inputField label="Label-2" value="..." />
    <apex:inputField label="Label-3" value="..." />
    <apex:inputField label="Label-4" value="..." />
</apex:pageBlockSection>

It looks like:

Label-1 Input-1         Label-2 Input-2
Label-3 Input-3         Label-4 Input-4

Now I want to add a custom selectList between fields 2 and 3:

<apex:inputField label="Label-1" value="..." />
<apex:inputField label="Label-2" value="..." />

<apex:outputLabel value="List Label:"/>
<apex:selectList value="..." size="1"> 
    <apex:selectOptions value="..." /> 
</apex:selectList>

<apex:inputField label="Label-3" value="..." />
<apex:inputField label="Label-4" value="..." />

This puts the selectList at the top of my pageBlockSection (before Label-1), not in second row and first column between fields 2 and 3. I tried to put selectList in apex:pageblocksectionitem, but it doesn't make a difference. How can I put the selectList between two other fields in a two column pageBlockSection?

0
3

apex:pageBlockSection by formats apex:inputField and apex:outputField.

For any custom input, one should use apex:pageBlockSectionItem inside apex:pageBlockSection.

An example below:

<apex:pageBlockSection title="Installation" > 
    <apex:inputField label="Label-1" value="..." />
    <apex:inputField label="Label-2" value="..." />

    <apex:pageBlockSectionItem>
        <apex:outputLabel value="List Label:"/>
        <apex:selectList value="..." size="1"> 
            <apex:selectOptions value="..." /> 
        </apex:selectList>
    </apex:pageBlockSectionItem>

    <apex:inputField label="Label-3" value="..." />
    <apex:inputField label="Label-4" value="..." />
</apex:pageBlockSection> 

From documentation of apex:pageBlockSectionItem:

A single piece of data in an that takes up one column in one row. An component can include up to two child components. If no content is specified, the column is rendered as an empty space. If one child component is specified, the content spans both cells of the column. If two child components are specified, the content of the first is rendered in the left, "label" cell of the column, while the content of the second is rendered in the right, "data" cell of the column.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.