• Manish Mahajan 34
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi,

I have a requirement where i want to save the labels of selected checkboxes in a textarea field.
I am pasting my code below. Please help me for the same
My Class:

public class getLabel{

public List<sObjectWrapper> wrappers{get;set;}  
public List<String> AllLabels{get;set;}
public getLabel(ApexPages.StandardController controller) {
AllLabels = new List<String>();

String type = 'ProposalFields__c';
Map<String, Schema.SObjectType> m = Schema.getGlobalDescribe();
system.debug('Map is --------------->'+m);

Schema.SObjectType s= m.get(type);
system.debug('Type is--------->'+s);

Map<String, Schema.SObjectField> fieldMap = s.getDescribe().fields.getMap();
system.debug('FieldMap is------------->'+fieldMap);

for (String fieldName: fieldMap.keySet()) {
System.debug('Field API Name*********'+fieldName);       // list of all field API name
String label = fieldMap.get(fieldName).getDescribe().getLabel();   //It provides to get the object fields label.
system.debug('Label is----------------->'+label);
AllLabels.add(label);
}
}

public class sObjectWrapper{  
    public boolean isSelected{get;set;}  
    public ProposalFields__c prop{get;set;}  
    public sObjectWrapper(ProposalFields__c prop,Boolean isSelected){  
    this.prop= prop;  
    this.isSelected = isSelected;  
 }  
 }

}


VF Page

<apex:page showHeader="false" sidebar="false" standardController="Proposal_Form__c" extensions="getLabel">
<apex:form >
<style>
.panelWrapper .mainTitle {
   
    
}
</style>
<apex:outputPanel styleClass="panelWrapper" layout="block">
<apex:pageBlock title="Proposal Form">
<apex:pageBlockSection title="Service Requirements">
<apex:inputField value="{!Proposal_Form__c.Service_Family__c}"/>
<apex:inputfield value="{!Proposal_Form__c.Service_Type__c}"/>
<apex:inputField value="{!Proposal_Form__c.Sub_Service_Category__c}"/>
</apex:pageBlockSection>

<apex:pageBlockButtons location="Bottom">
<apex:commandButton value="Save" action="{!Save}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Available fields">
<apex:pageBlockTable var="lab" value="{!AllLabels}">
<apex:column headerValue="Labels">{!lab}</apex:column>

<apex:column >   
<apex:inputCheckbox />
</apex:column> 

</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:outputPanel>

</apex:form> 
</apex:page>