1

I have a form in Lightning Components written using lightning:recordEditForm. Inside that form I have lightning:inputField which is a lookup. Is it possible to set a custom placeholder in this input?

EDIT: My lookup field is to object Employee. Therefore, the placeholder generated automatically is 'Search Employee'. I'm wondering if this is possible to change this placeholder.

  • Can you provide a bit of more detail, as what do you mean by custom placeholder? – Jayant Das Aug 17 '18 at 20:45
  • @JayantDas yes, I edited my post – rmatusiak Aug 17 '18 at 21:27
  • It doesn't seem to be that you can use a custom placeholder. Even though this component is derived from input tag which has a placeholder attribute, but using that on the inputField has no effect. I am not sure and not a css expert, if there's a way to do so using some custom css which can render the placeholder text. – Jayant Das Aug 17 '18 at 21:39
2

It seems you cannot provide a custom placeholder text in lookup fields while using lightning:inputField.

Even though the component is rendered as an input type=text with a placeholder attribute you can't override the attribute.

As an example, if I provide something as below:

<lightning:inputField fieldName="AccountId" aura:id="aId"/>

I can see this rendered as below (removed other attributes) with the placeholder attribute in there:

<input id="input-4" type="text" placeholder="Search Accounts..." class="slds-input slds-combobox__input slds-input-has-icon_group-right">

However if I provide the placeholder attribute something as below (the compiler does not complain), but it never works and that the placeholder attribute always had "Search Accounts..." in there and was never overridden.

<lightning:inputField fieldName="AccountId" aura:id="aId" placeholder="My Text"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.