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
Joe SalesvueJoe Salesvue 

Visualforce Issue with Default Values on Input Fields after Rerender

There appears to be a bug in Visualforce where inputField defaults do not display if the field is initially hidden and then a rerender displays the field.  If the field is initially visible then the default value is displayed on page load and after a rerender.  I have tested this on the latest API (32.0) and have a simple page example below that can be used to try to reproduce the issue.  In the code example below, the TrackingNumber__c field on opportunity has a default formula value of $User.LastName.  When you click the refresh button it will set a boolean flag (show) which will cause the inputfield to be displayed after the rerender completes.  If you remove the rendered attribute hiding the inputfield you will notice that the field default does display correctly even if you hit the refresh button.

<apex:page standardcontroller="opportunity" extensions="testoppextension">
    <apex:form id="frm">

        <apex:inputField value="{!opportunity.TrackingNumber__c}" rendered="{!show}"/>
        <apex:commandButton value="refresh" action="{!refresh}" rerender="frm"/>

public class testoppextension {

    public boolean show {get;set;}
    public testoppextension(ApexPages.StandardController std){
        show = false;
    public void refresh(){
        show = true;
Best Answer chosen by Joe Salesvue
Frédéric TrébuchetFrédéric Trébuchet

All Answers

Frédéric TrébuchetFrédéric Trébuchet
This was selected as the best answer
Frédéric TrébuchetFrédéric Trébuchet

Did this answer helped you? If so, feel free to mark the question as Solved and kindly select the best answer of your choice!