Usage of force:inputField and Its working

force:inputField component is used to display fields of a particular sObject with the appropriate type.  In other words, we don’t have to explicitly specify the type of the field. The component automatically renders the type.

For example: If the type of the field is date, then displays the Data Picker. Similarly if it is picklist, then a dropdown appears.

Consider the following code of force:inputField :
Component Code

 

Controller Code

 

Apex Code

Note:

  1. In the above component, we used this with value attribute only. The component renders the type as text input for LastName, and picklist for the CleanStatus field.
  2. This component doesn’t use the lightning Design System styling. Use lightning:input if you want an input field that inherits the Lightning Design System styling.
Output:

Force Input Field Output

Try demo:

 

 

For more details refer to
https://developer.salesforce.com/docs/component-library/bundle/force:inputField/specification

Write a Response

Your email address will not be published.


Find Out How We Can Help

If you're ready to find out more about how SimplusLabs can help energize your workers, your customers, and your business with a different experience, let's talk.