Search code examples
salesforceapex-codevisualforce

How do I dynamically set the 'mode' attribute of a apex:pageBlock in Salesforce Visualforce?


I have the following in my visualforce page:

<apex:pageBlock mode="{!pageBlockMode}">
</apex:pageBlock>

And a custom extension with this apex code:

public string pageBlockMode 
{ 
    get { return 'edit'; } 
}

Does anyone know why this doesn't work? It's simply defaulting to 'detail' mode. Is there a way to dynamically change the 'mode' attribute of a pageBlock?


Solution

  • It looks like my original code works now. Not sure which version of Visualforce this was fixed/changed in:

    Page:

    <apex:pageBlock mode="{!pageBlockMode}">
    </apex:pageBlock>
    

    Controller:

    public string pageBlockMode 
    { 
        get { return 'edit'; } 
    }