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
steve_andersensteve_andersen 

Can I pass a value to an inputField?

I want to create a simple one page wizard that is hit from a link off an Opp. The goal is to create a new Opp, after letting the user select a different Account and set values for some Opp fields. I thought I would use the standard Opp controller and then just pass some values to pre-populate the inputFields, but I can't figure out how to do that:

Code:
<apex:page standardController="opportunity">
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Choose an Organization</h1>
  <apex:form>
  <apex:inputField id="newOppAccountId" value="{!opportunity.accountid}"/> <p/>
  <apex:inputField id="newOppCloseDate" value="{!opportunity.closedate}"/> <p/>
  <apex:inputField id="newOppAmount" value="{!opportunity.amount}"/> <p/>
  <apex:inputField id="newOppName" value="{!opportunity.name}"/> <p/>
  <apex:commandButton action="{!save}" value="Create Matching Gift"/>
  </apex:form>
  <!-- End Default Content REMOVE THIS -->
</apex:page>

 Ideally, I'd just grab some values off the querystring and set the inputFields to them. I can't find any examples or threads where this is addressed. Am I off the mark?

Thanks!

Steve
steve_andersensteve_andersen
Ron,

Seems like part of your answer got deleted. Should there be something between the first and second lines?

Thanks,
Steve
steve_andersensteve_andersen
I created an extension to the standard controller and now my save() function works fine.

I created a constructor to try to preset the inputFields, but no dice:

Code:
 public matchingGiftExtension(ApexPages.StandardController stdController) {
        this.opportunity= (Opportunity)stdController.getRecord();
        opportunity.name = 'test name';

}

 I feel like I'm missing something basic.

Thanks,
Steve

dchasmandchasman
What you are attempting should work and I have verified that this is a controller extension initialization sequence bug. I have a fix for the problem in the hopper for the first Summer '08 patch.


Message Edited by dchasman on 05-14-2008 08:37 PM
steve_andersensteve_andersen
Thanks!

Steve