I can create a link or button in a visualforce page that references an object's links or buttons with a line like this:
<apex:commandButton action="{!URLFOR($Action.SiteProgram__c.New_Holidaybtn)}" ...
but when I do this, any default values that I've set via constructs like this "{!SiteProgram__c.Name}" in the original button or link show up blank. Here's the code for the button. I've checked the ID ("00N00000008igMg") and it is correct for the field in the new object.
/a0e/e?CF00N00000008igMg={!SiteProgram__c.Name}&CF00N00000008igMg_lkid={!SiteProgram__c.Id}&retURL={!SiteProgram__c.Id}
The Visualforce page uses the object's standard controller. The object is a custom object. What have I missed? Can this be done with a standard controller? I realize it could be done with a controller extension, but I'm hoping to keep this simple(r).
Here's the full VF page code.
<apex:page standardController="SiteProgram__c" docType="html-5.0" standardStylesheets="false" showheader="false" sidebar="false">
<apex:form >
<apex:outputLabel value="Site: " for="SiteOF"/>
<apex:outputField label="Site" id="SiteOF" value="{!SiteProgram__c.Name}"/><br/>
<apex:outputLabel value="District: " for="DistrictOF"/>
<apex:outputField label="District" id="DistrictOF" value="{!SiteProgram__c.SchoolDistrictProgram__c}"/><br/>
<apex:outputLabel value="Start Date: " for="StartDateOF"/>
<apex:outputField id="StartDateOF" value="{!SiteProgram__c.Start_Date__c}"/><br/>
<apex:outputLabel value="End Date: " for="EndDateOF"/>
<apex:outputField id="EndDateOF" value="{!SiteProgram__c.End_date__c}"/> <br/>
<apex:commandButton action="{!URLFOR($Action.SiteProgram__c.New_Holidaybtn)}" value="Create New Holiday" id="whatevs"></apex:commandButton>
<apex:commandButton action="{!URLFOR($Action.SiteProgram__c.New_Holidaylnk)}" value="Create New Holiday" id="whatevs6"></apex:commandButton>
</apex:form>
</apex:page>
edited to add I'm not going to add my own answer yet as I'd still like to know how to use URLFOR with $Action and passed inputs.
I tried many variations on the following including using commandlink instead of commandbutton:
<apex:commandButton action="{!URLFOR($Action.SiteProgram__c.New_Holiday,null,[CF00N00000008igMg=SiteProgram__c.Name,CF00N00000008igMg_lkid=SiteProgram__c.ID,saveURL=SiteProgram__c.ID])}" value="Create New Holiday" id="whatevs66"></apex:commandButton>
as there seems to be some disagreement out there about quotes and param names I also tried
<apex:commandButton action="{!URLFOR($Action.SiteProgram__c.New_Holiday,null,['CF00N00000008igMg'=SiteProgram__c.Name,'CF00N00000008igMg_lkid'=SiteProgram__c.ID,'saveURL'=SiteProgram__c.ID])}" value="Create New Holiday" id="whatevs66"></apex:commandButton>
In all cases, the resulting URL had the parameter names but blank values. I suspect the parameter names came from the underlying action, but I haven't tested that out yet.
Solution - replaces a previous answer based on straight URL hacking
The key point here is that the values between the square brackets "[]" (URLFOR parameter 3) have their own syntax. The URLFOR call is within the bounds of the the curly brackets "{}", so I suspect the rule switch is necessary to avoid confusion. Text needs to quoted (eg, 'CF00N00000008igMg_lkid') and variables don't need any special decoration. The equals sign does not need quotes. Concatenating values requires a "&".
<apex:commandButton action="{!URLFOR($Action.Holiday__c.New,null,['CF00N00000008igMg'=SiteProgram__c.Name,'CF00N00000008igMg_lkid'=SiteProgram__c.ID,'saveURL'='apex/SimpleSiteProgram?id='&SiteProgram__c.ID])}" value="Create New Holiday" id="holidaybtn"></apex:commandButton>