0

我有以下要求来创建一个 VF 页面 - '注册论坛' 具有 1.Name 字段 2.Age 字段 3.Project Unit 字段 4.Gender 作为具有值的单选按钮 - M 和 F 5.Certification 作为具有值的选项列表 - PD1, ADM 201、PD2、App Builder、Sales Cloud、Service Cloud 6.2 按钮——保存和重置 7.附件区域——我们可以在那里浏览和添加任何文档。

保存按钮- 应该在一个对象中创建记录(您可以提及的任何对象) 重置按钮- 页面不应该被刷新,只是用空白值刷新值。

由于我是 SFDC 的新手,您能帮我完成它吗?

谢谢

4

2 回答 2

0

很难从您的问题中确切地看出您在寻找什么,但这里有一个 visualforce 页面,它保存到一个名为 Form__c 的自定义对象中。要进行保存和重置,您可能需要 Apex 扩展。我不确定您的浏览文档是针对 Salesforce 文档还是本地文件。

<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>
于 2017-07-10T19:40:30.597 回答
0

您好,这是您要求提交表单的示例代码。我已经创建了自定义对象Registration_Forum__c

点击查看自定义对象注册_论坛__c图片

<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'));
}

}
于 2017-07-11T14:09:15.650 回答