Search code examples
salesforcevisualforceapex

Formatting Apex input field labels in a repeat


I have a field set in SF that I am using in a Visual Force page and the formatting of the field labels is not cooperating exactly.

Here is my code.

<apex:pageblocksection columns="1" title="[...]" collapsible="false">
    <apex:repeat value="{!fields2}" var="c">
        <apex:inputfield value="{!ghostacc[c.fieldPath]}" required="true" style="white-space: nowrap; position: relative;"/> 
    </apex:repeat>      
</apex:pageblocksection>

The result is a label for the input field that allows for word wrap. Is there something that I am missing?

Thank you!


Solution

  • style attribute on <apex:inputField> applies to the input itself, not the label next to it.

    Try explicitly specifying the label and the input, something like this?

    <apex:pageBlockSectionItem>
        <apex:outputLabel value="{!c.label}" style="nowrap magic goes here">
        <apex:inputfield value="{!ghostacc[c.fieldPath]}" required="true" />
    </apex:pageBlockSectionItem>