I'm trying to dynamically set the showDatePicker
attribute 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?
-
possible duplicate of VF Page: Best way to avoid datepicker focus on load?– Adrian Larson ♦Commented May 18, 2015 at 22:59
1 Answer
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