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
jucuzoglujucuzoglu 

How do I staticaly set the value of a hidden form field on my sites page?

When a user updates a record from a particular page via sites I want to add a Hidden Form Field value that the user cannot see that will set a checkbox on the record from false to true.

 

How do I accomplish this?

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

 

<apex:page standardController="Account" extensions="myAccountExtension">
   <!-- YOUR CODE HERE -->
</apex:page>

 

public class myAccountExtension {
  public myAccountExtension(ApexPages.StandardController controller) {
    Account a = (account)controller.getRecord();
    a.MyHiddenField__c = true;
  }
}

Extensions are covered in Visualforce Developer's Guide and the Apex Code Developer's Guide under their respective sections. 

 

All Answers

Alex_ConfigeroAlex_Configero

 

Something like:

 

 

<input type="hidden" value="SOMEVALUE" name="hiddenfield" />

 

THn you need to process that through the controller. Do you have any code that we can look at if this diesn't help you out?

 

sfdcfoxsfdcfox

You really should do this via the controller or extension for that page. That's what extensions and so on are there for.

jucuzoglujucuzoglu

I am using the standard controller. Can you point me to a document that shows a controller being extended?

 

sfdcfoxsfdcfox

 

<apex:page standardController="Account" extensions="myAccountExtension">
   <!-- YOUR CODE HERE -->
</apex:page>

 

public class myAccountExtension {
  public myAccountExtension(ApexPages.StandardController controller) {
    Account a = (account)controller.getRecord();
    a.MyHiddenField__c = true;
  }
}

Extensions are covered in Visualforce Developer's Guide and the Apex Code Developer's Guide under their respective sections. 

 

This was selected as the best answer