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.

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>
| improve this answer | |
  • why the negative vote? – AtulRajguru9 Jun 16 '14 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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.