• rchander
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

I'm having a problem with the firstname and lastname inputField on my visualforce page designed to create a new Person Account. The input field for the first and last name fields are showing up as non-editable. I have read several posts and am attempting to set the recordTypeID in the controller, but as you will see in my simple example it does not appear to be setting properly.  Any help with the following greatly appreciated.

 

Page:

<apex:page controller="newPersonAccountController" tabStyle="Contact">
<apex:sectionHeader title="New Person Account Header"/>
<apex:form >
<apex:pageBlock title="New Person Account Block">

<apex:facet name="footer">
<apex:commandButton action="{!save}" value="Save" styleClass="btn"/>
</apex:facet>

<apex:pageBlockSection title="Person Account Section">
<apex:panelGrid columns="1">
<apex:inputField value="{!PersonAccount.phone}"/>
<apex:inputField value="{!PersonAccount.firstname}"/>
<apex:inputField value="{!PersonAccount.lastname}"/>

<apex:outputLabel value="{!PersonAccount.RecordTypeID}"/>
<apex:outputLabel value="{!PersonAccount.isPersonAccount}"/>
</apex:panelGrid>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Controller:

 

/*
* This class is the controller behind the New PersonAccount
* wizard.
*/

public class newPersonAccountController {

// Variables
account PersonAccount;

// Get methods.

public account getPersonAccount() {
if(PersonAccount == null) PersonAccount = new account(RecordTypeId='012A000000006JQ', firstname='Sammy', lastname='Snead');
return PersonAccount;
}

// This method performs the save for both objects, and
// then navigates the user to the detail page.
public PageReference save() {

// Create the account.
insert PersonAccount;

// Finally, send the user to the detail page

PageReference providerPage = new PageReference('/' + PersonAccount.id);

providerPage.setRedirect(true);
return providerPage;
}
}

 

Results:

 

The vf page displays with phone as an editable field and firstname and lastname as non-editable fields.  The recordtypeID is displayed, the isPersonAccount field shows as false.  The record DOES save correctly and creates the person account with the correct record type. 

 

Any thoughts on how to get the firstname and lastname fields to be editable fields, or any relavent sample code greatly appreciated.

 

 

Thanks!
Message Edited by ocsden1 on 07-14-2009 09:39 AM