0

I have below requirement to Create a VF page – ‘Registration Forum’ having 1.Name field 2.Age field 3.Project Unit field 4.Gender as Radio Button with values – M and F 5.Certification as Picklist with Values – PD1, ADM 201, PD2, App Builder, Sales Cloud, Service Cloud 6.2 buttons – save and reset 7.Attachment area – where we can browse and add any document there.

Save Button – A record should get created in one object (Any object u can mention) Reset Button – Page should not get refreshed, just values get refreshed with blank value.

As I am new to SFDC, could you please help me to get it done?

Thanks

Praveen Verma
  • 41
  • 1
  • 10

2 Answers2

0

It's hard to tell from your question exactly what you're looking for, but here is a visualforce page that saves to a custom object called Form__c. To do the save and reset you'll probably need an Apex extension. I'm not sure if your browse documents is for Salesforce documents or local files.

<apex:page standardController="Form__c" >
  <apex:form>
    <apex:pageBlock>
      <apex:pageBlockButtons>
        <apex:commandButton value="Save" action="{!save}" />
      </apex:pageBlockButtons>
      <apex:pageBlockSection>
        <apex:inputField value="{!Form__c.Name}" />
        <apex:inputField value="{!Form__c.Age__c}" />
        <apex:inputField value="{!Form__c.Project_Unit__c}" />
        <apex:selectRadio value="{!Form__c.Gender__c}" ><apex:selectOption itemValue="Male" itemLabel="Male" /><apex:selectOption itemValue="Female" itemLabel="Female" /></apex:selectRadio>
     </apex:pageBlockSection>
    </apex:pageBlock>
  </apex:form>
</apex:page>
Matt Kaufman
  • 748
  • 4
  • 12
0

Hi here is the sample code for your asking for form submission.i have create custom object Registration_Forum__c.

Click to see Custom Object Registration_Forum__c Image

<apex:page Controller="VFFileUpload">
<apex:pageMessages id="showmsg"></apex:pageMessages>
<apex:form>
<apex:pageBlock title="Upload Attachment">

<apex:pageBlockButtons location="top">
    <apex:commandButton value="Save" action="{!saveForm}"  />
    <apex:commandButton value="reset" action="{!resetForm}"  />
</apex:pageBlockButtons>

    <apex:pageBlockSection>
        <apex:inputField value="{!Registration_Forum.Name}" />
        <apex:inputField value="{!Registration_Forum.age__c}" />
        <apex:inputField value="{!Registration_Forum.Certification__c}" />
        <apex:inputField value="{!Registration_Forum.Project_Unit__c}" />
        <apex:selectRadio value="{!Registration_Forum.Gender__c}">
            <apex:selectOption itemValue="Male" itemLabel="Male" />
            <apex:selectOption itemValue="Female" itemLabel="Female" />
        </apex:selectRadio>
      <apex:inputFile id="file" value="{!fileBody}" filename="{!fileName}" /> 
    </apex:pageBlockSection>

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




public class VFFileUpload
{
public Registration_Forum__c Registration_Forum{get;set;}
public String fileName {get;set;}
public Blob fileBody {get;set;}

public VFFileUpload()  {
    Registration_Forum=new Registration_Forum__c();
}

public void saveForm(){
     upsert Registration_Forum;
     if(fileBody != null && fileName != null && Registration_Forum.id!=null)
    {
      Attachment myAttachment  = new Attachment();
      myAttachment.Body = fileBody;
      myAttachment.Name = fileName;
      myAttachment.ParentId = Registration_Forum.Id;
      upsert myAttachment;
      ApexPages.addmessage(new ApexPages.message(ApexPages.severity.info,'File Upload  Success'));
    }
     ApexPages.addmessage(new ApexPages.message(ApexPages.severity.info,'Form Submission Success'));
}

public void  resetForm(){
    Registration_Forum=new Registration_Forum__c();
      ApexPages.addmessage(new ApexPages.message(ApexPages.severity.info,'Reset'));
}

}
NITHESH K
  • 128
  • 2
  • 9