Skip to main content

Hello Experts,

  • I have one apex class and I displaying the list of fileds from FieldSet on VF page.
  • There are some input fields, which i want in my apex code.

    <!-- VF Page Snippet-->

    *******

    *******

    <apex:repeat value="{!fields}" var="f">

    <apex:outputText value="{!f.Label}"/>

    <apex:inputText WHAT_LOGIC_I_SHOULD_USE_HERE /> <br/>

    </apex:repeat>

    *******

    *******

    /* Apex Code Snippet */

    public List<Schema.FieldSetMember> getFields()

    {

    return SObjectType.Contact.FieldSets.Quiz_Field_Set.getFields();

    }

  • Whatever values I put into Input Text Box, that all value I want into my Apex Code.
5 answers
  1. Apr 21, 2017, 11:34 AM

    You need to declare a get, set for Contact object in the controller as follows:

    public class VFTestController {

    public Contact objContact {get; set;}

    }

    Then you need to modify code of your visualforce page as follows:

    <apex:repeat value="{!fields}" var="f">

    <apex:outputText value="{!f.Label}"/>

    <apex:inputField value="{!objContact[f.fieldPath]}" /> <br/>

    </apex:repeat>

    You can then debug the objContact variable in the controller to get the values of the fields set using the visualforce page.

    For more details on working with the fieldsets, go through this documentation on fieldsets: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_dynamic_vf_field_sets.htm

    Thanks,

    Vivek Shinde
0/9000