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. If the component corresponds to a date field, a date picker is displayed in the field. Similarly, if the component corresponds to a rich text area, the input field is rendered as a rich text editor. Dependent picklists are not supported. Required fields are not enforced client-side.
Bind the field using the value attribute and provide a default value to initialize the object.
<aura:attribute name="contact" type="Contact" default="{ 'sobjectType': 'Contact' }"/> <force:inputField aura:id="contactName" value="{!v.contact.Name}"/>
In this example, the v.contact.Name expression bounds the value to the Name field on the contact. To load record data, wire up the container component to an Apex controller that returns the data. See Working with Salesforce Records in the Lightning Components Developer Guide for more information.
This component doesn't inherit the Lightning Design System styling. Use lightning:input if you want an input field that inherits the Lightning Design System styling.
Attribute Name | Attribute Type | Description | Required? |
---|---|---|---|
body | Component[] | The body of the component. In markup, this is everything in the body of the tag. | |
class | String | The CSS style used to display the field. | |
errorComponent | Component[] | A component which is responsible for displaying the error message. | |
required | Boolean | Specifies whether this field is required or not. | |
value | Object | Data value of Salesforce field to which to bind. |
Event Name | Event Type | Description |
---|---|---|
change | COMPONENT | The event fired when the user changes the content of the input. |