function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kkaalkkaal 

Create empty form

I am developing a VF page which uses data from several objects and should work as an empty form. As soon as I press the save button, I want to save and link the objects.

 

So, I have my standardController. The datafields of which work fine in my form.

 

Then I created this Controller as an extension and just have an Account from which (in this example) just show the inutField of FirstName:

 

 

public class MatchCheckController {

    public Account account{get; set;}


    public MatchCheckController(ApexPages.StandardController controller) {
           
           account = new Account(           
           FirstName='',
           RecordTypeId='01220000000Pn0EAAS'
           );
           
    }

 

My problem: on my VF page, it does not show the inputFiled.

When I populate the FirstName with any string, this is output at the place where the inputField should be. But not editable and no frame around it.

 

What is the "official" way of creating a empty form with datafields in an extension object?

 

aballardaballard

Does the user you are testing with have access to create/edit accounts?  

kkaalkkaal

Absolutely, yes. I am admin.

kkaalkkaal

I have created a testpage. This page shows in result just the "Name" editfield and the "Save" button. It does not render, as expected the edit fields for Firstname and LastName.

 

Can you tell me what is wrong?

 

VF page:

 

<apex:page Controller="MyController">

      <!-- just to be sure -->
      <apex:outputField value="{!Account.isPersonaccount}" rendered="false"/>
      <apex:outputField value="{!Account.RecordTypeId}" rendered="false"/>
      
      <apex:form >
               <apex:inputField id="FirstName" value="{!Account.FirstName}"/>
               <apex:inputField id="LastName" value="{!Account.LastName}"/>
               <apex:inputField id="Name" value="{!Account.Name}"/>
               <apex:commandButton value="Save" action="{!save}"/>
      </apex:form>
      
</apex:page>

 

 

The controller:

 

public class MyController {
    
    Account account;

    public Account getAccount() {
    
        if(account == null){
            account = new Account();
            //this is the recordTypeId for PersonAccount
            account.RecordTypeId = '01220000000Pn0EAAS'; 
        }
        return account;
    }

     public PageReference save(){
          // dummy function
              return null;
     }

}

 

 

Can you tell me what is wrong?

Thanks

kleinaItalienerkleinaItaliener

Hello everybody,

 

i have the same problem!

 

Pleas help me :smileysad: to find a solution ...

 

TXs