You need to sign in to do that
Don't have an account?

i have created a fieldset in contact object and retrived some fields like firstname,lastname.email,phone etc and display all the fields as a form in lightning component like this
<aura:iteration items="{! v.fields }" var="field">
<div class="slds-size_5-of-12">
<lightning:input aura:id="idName" label="{!field.Label}" required="{!field.DBRequired}" type="{!field.Type}" class="slds-p-top_small slds-m-top_medium" />
</div>
<div class="slds-size_1-of-12"></div>
</aura:iteration>
and i want ,whatever i type in input box of firstname,lastname or whatever the value of that field should be store in attribute of type Contact otherwise i want all the data as Json in lightning component Js controller Please help me to solve this...
<div class="slds-size_5-of-12">
<lightning:input aura:id="idName" label="{!field.Label}" required="{!field.DBRequired}" type="{!field.Type}" class="slds-p-top_small slds-m-top_medium" />
</div>
<div class="slds-size_1-of-12"></div>
</aura:iteration>
and i want ,whatever i type in input box of firstname,lastname or whatever the value of that field should be store in attribute of type Contact otherwise i want all the data as Json in lightning component Js controller Please help me to solve this...
FYI
Controller Code : If you are using jquery Controller code with simple javascript
Hope this will help you. Check out te consoles printed.
Thanks,
Sanjay
Thanks for reply
Instead of Json like this as your code is printing in console
My JSON DATA : {"fieldList":[{"fieldValue":"dfsg"},{"fieldValue":"fdsg"},{"fieldValue":null},{"fieldValue":null},{"fieldValue":null},{"fieldValue":null},{"fieldValue":null},{"fieldValue":null},{"fieldValue":null},{"fieldValue":null}]}
I want to print JSOn like this
My JSON DATA : {"fieldList":[{"FirstName":"dfsg"},{"LastName":"fdsg"},{"Email":null},{"AssistantPhone":null},{"MailingStreet":null},{"MailingCity":null},{"MailingPostalCode":null},{"MailingState":null},{"MailingCountry":null},{"MailingPostalCode":null}]}
All my APi name are in the name attribute of lightning input you can see in bold text as below
<aura:iteration items="{!v.fields }" var="field" indexVar="listIndex">
<div class="slds-size_5-of-12">
<lightning:input aura:id="idName" name="{!field.APIName}" label="{!field.Label}" required="{!field.DBRequired}" type="{!field.Type}" class="slds-p-top_small slds-m-top_medium" />
</div>
<div class="slds-size_1-of-12"></div>
</aura:iteration>