function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
丹 朱丹 朱 

How to set the value of lightning:inputField?

I hava a lightning:inputField.
I want to set the value of lightning:inputField by code?
The first time can set.
The second time can set the value,  but the placeholder content can't change.
How to set the value of lightning:inputField , and set the placeholder content of lightning:inputField ?
Who can help me???
Thank you!!!Thank you!!!
NagendraNagendra (Salesforce Developers) 
Hi,

May I request you please confirm the data type of the field on which you want to set the placeholder content if Lightning input field?

If it is a lookup field 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"/>
Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
 
丹 朱丹 朱
Hi Nagendra,
Thank you very much, Your answer is very detailed and helpful!!! 
Thank you!!!

But I would like to continue asking.
JavaScript can't you set it?