2

I have created field set and using it in visualforce page, I have included all the fields from field set in viusalforce page using but there is an issue with the css, css is not working properly my code is,

Visualforce Page

<div class="slds-form-element__control">
   <apex:repeat value="{!FieldfrmFieldSet}" var="fs">         
        <label class="slds-form-element__label" for="text-input-01">{!fs.label}</label>
        <apex:inputfield styleClass="slds-select" value="{!objContact1[fs]}" required="{!OR(fs.required, fs.dbrequired)}"/>
   </apex:repeat>
</div> 

My Controller

public class FieldSetController {

    public Contact objContact1{get;set;} 

    public FieldSetController()
    {
      objContact1 = new Contact();
    }

    public List<Schema.FieldSetMember> getFieldfrmFieldSet()
    {
      return SObjectType.Contact.FieldSets.New_Contact.getFields();
    }
}

Problem in css enter image description here

I'm sharing the screenshot.. the css is not working properly.. If I scroll the page position for lookup icons also changes..

I'm expecting like this enter image description here

  • why don't you use pageBlockTable?. Correct me if I'm wrong. – Rohit Mourya May 15 '17 at 8:51
  • @Rohit Mourya still I have to use <apex:repeat> to iterate through fields... again the issue is same with css.. is their any way include fields in vf page directly instead of <apex:repeat> .. – Atul Rakate May 15 '17 at 9:10
1

Directaly use FieldSet into Vf page:

Vf Page:

<apex:repeat value="{!$ObjectType.ObjectName.FieldSets.FieldSetName}"  var="field">
        <apex:inputField value="{!ObjectRecord[field.fieldPath]}"
                         required="{!OR(field.required, field.dbrequired)}" />
</apex:repeat>

In Controller assign memory for object:

Public class Controller {
    public Object ObjectRecord {get; set;}
    // Constructor
    public Controller(ApexPages.StandardController controller) {
       ObjectRecord = new object();
    }
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.