0

In Salesforce record, the time field shows as a picklist but when I add the same time field to Visualforce page in a form, it only displays as a text field. Am I missing anything here?

Visualforce:

<apex:outputPanel id = "CleaningSection" styleClass="grey" layout="block">
          <apex:pageBlockSection columns="2" title="Cleaning Activity" id="section1" collapsible="false">
                            <apex:inputField  value="{!cle.Start_Time__c}"/>
                        </apex:pageBlockSection> 
                    </apex:outputPanel>

Controller (sample snippet):

public class i2{
public Cleaning_Activity__c cle{get;set;}
public Permit_to_Work_Number__c ptw{get;set;}
public List<Cleaning_Activity__c> clelist{get;set;}
public String paramValue{get;set;}

//constructor to create a new record
public i2(){
    cle = new Cleaning_Activity__c();
    ptw = new Permit_to_Work_Number__c();  

}}

Result:

It doesn't display as picklist.

1 Answer 1

0

You can use type attribute in inputfield like this

  <apex:inputField  value="{!cle.Start_Time__c}" type="time"/>

you would also need to include docType as html-5.0 like this

<apex:page standardController="Account"  lightningStylesheets="true"  docType="html-5.0" >
2
  • Thank you so much!! It worked! Although it doesn't look the same as what we see in a salesforce record. Do you have any suggestions as to how to make the time field the same as that is present in SF record? Commented May 20, 2020 at 2:59
  • @krishnamurthy i guess the best we can do with inputField of type "time" here is add styleClass="slds-input",to make it exactly similar we probably have to write it full custom.
    – User6670
    Commented May 20, 2020 at 8:46

You must log in to answer this question.

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