我有以下要求创建一个VF页面 - '注册论坛'有 1.Name字段 2.Age领域 3.Project Unit字段 4.Gender作为单选按钮的值 - M和F. 5.认证为具有价值的领料单 - PD1,ADM 201,PD2,App Builder,Sales Cloud,Service Cloud 6.2按钮 - 保存并重置 7.Attachment area - 我们可以在那里浏览和添加任何文件。
保存按钮 - 应在一个对象中创建记录(您可以提及的任何对象) 重置按钮 - 页面不应刷新,只是使用空值刷新值。
由于我是SFDC的新手,您能帮助我完成它吗?
由于
答案 0 :(得分: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>
答案 1 :(得分:0)
您好,这是您要求表单提交的示例代码。我已创建自定义对象 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'));
}
}