At the moment I have a custom VF page with fields that look this:

<apex:inputField value="{!contact.name}"/>
<apex:inputField value="{!contact.email}"/>
<apex:inputField value="{!message.Body__c}" />

When submitted, the contact information will come through to the controller function I wrote inside a ContactExtension Controller that was made but the message object will be null.

public class ContactExtension {
    public Contact contact { get; set; }
    public List<string> VideoIds {get; set;}
    public Message__c message {get; set;}

    // Example function
    public PageReference send () {
// Result
DEBUG|Contact:{Email=dean@example.com, Id=00328000003QkVmAAK, Name=Dean D, FirstName=Dean, LastName=D}

Is there something else I need to define to allow the Message model to be passed through the form into the action?


Perhaps the contact reference is working because your standard controller is for Contact and it is taking care of querying/newing the Contact object.

But for your message reference, you will need to create a new object (and also insert it later if you want to save it). One way to do that is to add this:

message = new Message__c();

to a constructor that you add to ContactExtension.

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.