I have a Visualforce custom object EDIT page with a controller extension that's used by multiple profiles. I've created a two-column layout by embedding the input fields in an <apex:pageBlockSection columns="2">
. I've tried to take advantage of the <apex:inputField>
's obedience to field level security (FLS) settings so some of my fields will display with one profile but not another.
The problem I'm having is with the column wrapping feature of the pageBlockSection
. If the field level security determines that a field cannot be displayed then it just displays the next field along. I would prefer to use the next field (down) from the right column rather than just the next field along (i.e. left). How can I prevent this default wrapping?
Code below – I have appended a COL_A / COL_B suffix to the ID just to indicate where I want the field to appear. If my FLS says I should not see "List_Price_Unit__c", then the next field just wraps into that position. Really I would prefer the columns to be fixed so the Requested_Net_Price_Unit__c label is pulled up one instead.
<apex:pageBlockSection title="Product Information" columns="2" id="speditsect">
<apex:inputField value="{!MyProduct__c.ProductName__c}" id="product_COL_A" required="true" taborderhint="1" />
<apex:inputField value="{!MyProduct__c.List_Price_Unit__c}" id="listprice_COL_B" required="true" taborderhint="2" />
<apex:inputField value="{!MyProduct__c.Enclosure__c}" id="enclosure_COL_A" required="true" />
<apex:outputText value="" label="{!$ObjectType.MyProduct__c.fields.Requested_Net_Price_Unit__c.Label}" id="newnetnetprice_COL_B" />
<apex:inputField value="{!MyProduct__c.Content_Price_Unit__c}" id="contentprice_COL_A" required="true" taborderhint="6" />
Best Answer
You can nest
<apex:pageblocksection>
elements with acolumns="1"
attribute to achieve this.