2

I have a Visualforce page to collect the Name and Email of clients. My Visualforce page looks like this:

<apex:page Controller="WebsiteController" >
<apex:sectionHeader title="Registration" subtitle="Please fill in the details"/>
    <apex:form >
        <apex:pageMessages />
        <apex:pageBlock title="Email updates">
        <apex:pageBlockButtons >
            <apex:commandButton action="{!submit}" value="Submit"/>
            <apex:commandButton action="{!reset}" value="Reset"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection >

//here is my problem: the page shows an input field for email, but not name
        <apex:inputField value="{!contact.Name}" required="true"/>
        <apex:inputField value="{!contact.Email}" required="true"/>
        </apex:pageBlockSection>
        </apex:pageBlock>
</apex:form>
</apex:page>

I have no idea why one input field is shown and the other is not - I am probably missing a small detail.

2 Answers 2

0

Contact.name is formula field which is read only.

Try this:

<apex:page standardController="Contact" >
<apex:sectionHeader title="Registration" subtitle="Please fill in the details"/>
    <apex:form >
    <apex:pageMessages />
    <apex:pageBlock title="Email updates">
    <apex:pageBlockButtons >
        <apex:commandButton action="{!Save}" value="Submit"/>
        <apex:commandButton action="{!Cancel}" value="Reset"/>
    </apex:pageBlockButtons>
    <apex:pageBlockSection >


    <apex:inputField value="{!contact.firstName}" required="true"/>
    <apex:inputField value="{!contact.Email}" required="true"/>
    </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>
1
  • why the negative vote? Commented Jun 16, 2014 at 12:22
0

Contact name is kind of formula field, it is concatenation of LastName and FirstName. And formula field can't be displayed as input. Try replace it by those two I suggested.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .