I have this Visualforce code:

    <apex:pageBlockSection title="Carry Over" columns="2">

        <apex:variable var="cnt" value="{!0}"/>

        <apex:repeat value="{!carryoverBuckets}" var="bucket">
            <apex:variable var="cnt" value="{!cnt+1}" />     
            <apex:inputField label="Carryover Period {!cnt} amount" value="{!bucket.Amount__c}" required="false"/>
            <apex:inputField value="{!bucket.Expiry_Date__c}" required="false"/>  


which is supposed to render inputfields along with their labels in 2 columns.

This works OK if I remove the <apex:variable/> tags and the {!cnt} from the label, but with those in place, the layout is broken.

If I use rendered="false" on the <apex:variable/> tags, then layout is restored, but the value of {!cnt} is not rendered, or is empty.

How can I correct the layout, and retain the value of {!cnt}?

  • When you say broken is the field not showing up on the VF page?can you post screenshot? – Rao Jun 24 '16 at 17:04
  • try to use apex:pageblocksectionItem – Tushar Sharma Jun 25 '16 at 8:55

Your Answer

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

Browse other questions tagged or ask your own question.