+ Start a Discussion
Kenneth Wang 1Kenneth Wang 1 

What is the difference between Field required and Field Set required

I wa confused about the attribute "required" in field and field set.

If an field is defined as required, will it be required without any configure in field set?

Hello Wang,

Take a look at the below code:
<apex:page controller="MerchandiseDetails">
    <apex:form >

      <apex:pageBlock title="Product Details">
          <apex:pageBlockSection title="Product">
              <apex:inputField value="{!merch.Name}"/>
          <apex:pageBlockSection title="Dimensions">
              <apex:repeat value="{!fields}" var="f">
                  <apex:inputField value="{!merch[f.fieldPath]}" 
                      required="{!OR(f.required, f.dbrequired)}"/>


One thing to note about the above markup is the expression used to determine if a field on the form should be indicated as being a required field.
A field in a field set can be required by either the field set definition, or the field’s own definition. The expression handles both cases.

For more deep dive : https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_dynamic_vf_field_sets.htm (https://help.salesforce.com/apex/HTViewHelpDoc?id=fields_required_field_sets.htm&language=en)

Hope this helps!

Note: Mark this as solution if this help in resolving.