I'm trying to dynamically set the showDatePickerattribute of an apex input field to get around a strange bug I've been experiencing. I've tried setting attributes using document.getElementbyID('{!component.id}').label="new label" and nothing seems to change even though the method is called. Do I need to rerender the input field or the panel that it's in for attribute changes to take effect or are they unchangeable after the window loads?


1 Answer 1


showDatePicker is a custom salesforce attribute. So if you want to change it on the page, you will have to assign it with a boolean property value in controller and rerender.

<apex:inputField value="{!object.DateField__c}" showDatePicker="{!booleanProperty}" id="fieldId"/>

Also as per salesforce documentation, it works only in some type of fields,

This attribute only affects date and datetime fields, and activating a browser-based type-appropriate selection widget requires the type attribute be set to one of these date- or time-compatible types:

  • date datetime datetime-local month week time

Label will be a rendering as a different label tag associated with the field. So if you use select field using javascript and change label, it will not change actual label of the field. Use inspect element/browser console to find rendered HTML elements and select accordingly

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .