Input Field

force:inputField

Provides a concrete type-specific input component implementation based on the data to which it is bound.

For Use In

Lightning Experience, Experience Builder Sites, Salesforce Mobile App

force:inputField represents an input field that corresponds to a field on a Salesforce object. This component respects the attributes of the associated field. For example, if the component is a number field with 2 decimal places, then the default input value contains the same number of decimal places. It loads the input field according to the field type. If the component corresponds to a date field, a date picker is displayed in the field. Dependent picklists and rich text fields are not supported. State and country fields in addresses display as read-only fields. Required fields are not enforced client-side.

force:inputField has been superseded by lightning:inputField. To create forms for Salesforce objects without using Apex controllers, use lightning:inputField with lightning:recordEditForm, or use lightning:recordForm. To create a generic input field, use lightning:input.

This example creates an input field that displays data for a contact name. Bind the field using the value attribute and provide a default value to initialize the object.

In this example, the v.contact.FirstName expression binds the value to the FirstName field on the contact. To load record data, wire up the container component to an Apex controller that returns the contact.

Pass the contact data to the component via a client-side controller.

Multi-select picklists display the API name of the field on the label, for example, MyPicklistField__c.

force:inputField doesn't use the Lightning Design System styling. If you're using force:inputField in a standalone app, this component doesn't support Lightning Design System styling from force:slds.

change

The event fired when the user changes the content of the input field and leaves the field.