How to refer object’s fields in Lighting Component?

How to refer object’s fields in Lighting Component?

<force:inputField> can be usedto refer object’s fields in Lighting Component.


Sample Code:

<aura:component implements=”force:appHostable”>
    
    <aura:attribute name=”oppty” 
                    type=”Opportunity” 
                    default=”{ ‘sobjectType’: ‘Opportunity’}”/>
<div class=”slds-box slds-theme_default”>
        <div class=”slds-grid slds-grid_vertical”>
            <div class=”slds-col”>
                Name<force:inputField value=”{!v.oppty.Name}”/>
            </div>
            <div class=”slds-col”>
                Amount<force:inputField value=”{!v.oppty.Amount}”/>
            </div>              
        </div>
    </div>
    
</aura:component>


Output:

Leave a Reply