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
DohDoh 

Field Sets rendered attribute not working

I'm dipping my toes with the new Field Sets (FS) feature and I really like it. It will reduce administration coding tremendously if you are a heavy VF user.

 

My problem is that I want to display different field sets based on the rendered attribute. The idea is that you have a master FS and clone variations that allow for context treatment in a page. The help text for the <apex:repeat > component inidcates tha rendered is a supported attribute.

 

My tests suggest that it is not yet supported. I set up a test object to test the feature:

 

I setup 2 FS called FS1 and FS2 where FS2 is a clone of FS1 but with an extra field.

The first 2 page sections make sure both field sets display.

The next page sections (3) checks that they display if incuded in the same page section.

Page Section (4) is to base a rendered on a boolean

"Field Set FS2 only if Field 1 true"

The final Page Section is a straight forward test: 

rendered="false">  

 

<apex:page standardController="Test_Field_Sets__c">
<apex:form >
  <apex:pageBlock title="Test Field Sets">
  
   <apex:pageBlockSection title="Show All Values" columns="1">
   
   <apex:outputField value="{!Test_Field_Sets__c.name}"/>
   <apex:outputField value="{!Test_Field_Sets__c.Field_1__c}"/>
   <apex:outputField value="{!Test_Field_Sets__c.Field_2__c}"/>
   <apex:outputField value="{!Test_Field_Sets__c.Field_3__c}"/>
   <apex:outputField value="{!Test_Field_Sets__c.Field_4__c}"/>
   
   </apex:pageBlockSection>
   
   <apex:pageBlockSection title="Field Set FS1" columns="1">
     <apex:repeat value="{!$ObjectType.Test_Field_Sets__c.FieldSets.FS1}" var="f">              
              <apex:outputField value="{!Test_Field_Sets__c[f]}"/>
            </apex:repeat>
   </apex:pageBlockSection>
   
   <apex:pageBlockSection title="Field Set FS2" columns="1">
     <apex:repeat value="{!$ObjectType.Test_Field_Sets__c.FieldSets.FS2}" var="f">              
       <apex:outputField value="{!Test_Field_Sets__c[f]}"/>
     </apex:repeat>
   </apex:pageBlockSection>
   
   <apex:pageBlockSection title="All Field Sets in one page section" columns="1">
     <apex:repeat value="{!$ObjectType.Test_Field_Sets__c.FieldSets.FS1}" var="f">              
       <apex:outputField value="{!Test_Field_Sets__c[f]}"/>
     </apex:repeat>
     <apex:pageBlockSectionItem />
     ********************************
     <apex:pageBlockSectionItem />
     <apex:repeat value="{!$ObjectType.Test_Field_Sets__c.FieldSets.FS2}" var="f">              
       <apex:outputField value="{!Test_Field_Sets__c[f]}"/>
     </apex:repeat>
   </apex:pageBlockSection>
   
   <apex:pageBlockSection title="Field Set FS2 only if Field 1 true" columns="1">
   
     <apex:repeat value="{!$ObjectType.Test_Field_Sets__c.FieldSets.FS1}" var="f">              
       <apex:outputField value="{!Test_Field_Sets__c[f]}"/>
     </apex:repeat>
     
     <apex:pageBlockSectionItem />
     ********************************
     <apex:pageBlockSectionItem />
     
     <apex:repeat value="{!$ObjectType.Test_Field_Sets__c.FieldSets.FS2}" var="f" rendered="{!Test_Field_Sets__c.Field_1__c}">              
       <apex:outputField value="{!Test_Field_Sets__c[f]}"/>
     </apex:repeat>
   </apex:pageBlockSection>
   
   <apex:pageBlockSection title="Field Set rendered test" columns="1">
     <apex:repeat value="{!$ObjectType.Test_Field_Sets__c.FieldSets.FS2}" var="f" rendered="false">              
       <apex:outputField value="{!Test_Field_Sets__c[f]}"/>
     </apex:repeat>
   </apex:pageBlockSection>
  </apex:pageBlock>
</apex:form>    
</apex:page>

 In all cases the rendered attribute is ignored. Since it is a beta release I'm inclined to think it is a feature bug? Anyone else seen the same issue?

 

forecast_is_cloudyforecast_is_cloudy

Instead of using the rendered attribute of the repeat tag, try using the rendered attribute of the pageBlockSection tag.

DohDoh

I agree that it would allow control of a single Field Set inside a page section as a work around but it would mean writing multiple page sections to cover every permutation of rendering. Before doing that I want to know if we have a bug since the component attribute is not working yet it is a documented feature unless I'm missing something.

 

Thanks for the suggestion.