0

I have a picklist in Salesforce that I am displaying on visualforce page. The picklist by default shows --None-- as an option. Instead of displaying None, I want to display Please Select or maybe leave it blank until user picks some option from the list.I tried using Html-placeholder with Input field but seems like it does not work:

Here is my visualforce code:

<apex:page showHeader="false" controller="PageController" sidebar="false"  applyBodyTag="false" docType="html-5.0">

    <apex:outputLabel value="Have you ever participated in high school extracurricular activities such as sports, bands or clubs?"/>

    <apex:inputField required="true" html-placeholder="**Please Select**" id="HS_Extracurricular_Participant__c" value="{!application.HS_Extracurricular_Participant__c}"/>
    </br></br> 
1
  • 2
    This is due to the picklist field type, not the apex:inputField. The first option of a select is indeed an option NOT a placeholder. The html-placeholder attribute does work for text-type fields when using an inputField. Commented Aug 27, 2018 at 20:39

1 Answer 1

3

The html-placeholder attribute is not supposed to work with field types of picklists.

placeholder is a HTML5 attribute and can be utilized as part of the HTML pass-through attributes on Visualforce pages. However if you look at the placholder reference, it can be only used with specific input field types as below, and that field types of picklist when rendered on Visualforce page when used with apex:inputField are rendered as select options.

Note: The placeholder attribute works with the following input types: text, search, url, tel, email, and password.

2
  • Thanks for replying. So I thought of an alternative. I added "Please select" as a picklist option and made it default but when I go back on visualforce page, it still shows none as default and it shows "Please select" as an option. How do I get rid of this None?
    – Student
    Commented Aug 27, 2018 at 22:53
  • That classifies as a different question. If you can post that as a separate question then someone can help you for that. With this one, the original issue is answered as why you were not able to use the attribute.
    – Jayant Das
    Commented Aug 27, 2018 at 23:11

You must log in to answer this question.

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