0

enter image description hereenter image description here`

` Can we use lightning design resource for mapping? I want to bind the apiName dynamically so what I am doing is like,

So at the time of component placement on a page from app builder, I have given input for TitleApi = FirstName so its not inserting data for FirstName. Can we use such a syntax like value="{!v.conInfo+'.'+v.TitleApi}"to make api name dynamic.

0

This is possible, but not via a direct binding in the component markup.

A couple of the options in JavaScript to achieve this are...

Generic object

  • Create a new attribute that is of generic Object type and bind this to the inputText component e.g. {! v.tempObj.value }

  • Add a change handler for the new Object attribute, and then in JavaScript update your Contact attribute with whatever was set, e.g. component.set("v.conInfo." + component.get("v.TitleApi"), component.get("v.tempObj.value"));

or...

Dynamic inputText creation

  • On init of your component, create the inputText component dynamically using $A.createComponent(). This will allow you to bind the inputText directly to the correct field on Contact.
3
  • Thanks. for more clarification, my requirement is like I have already working component I am taking some inputs while placement of the component in-app builder through design resource. And inputs are nothing but field API names so I want to replace it like value={!v.objRef.fieldName1} to -----> value={!v.objRef.fieldName2} where I will provide input for fieldName2 through design resource – optimistic_cloud Dec 29 '18 at 17:59
  • Yep, understood. The second option in my answer is probably best for your use case. Click the link in my answer to view the documentation for $A.createComponent(). You can create the ui:inputText component and bind it to whatever field the admin entered in App Builder. – TheCloudFox Dec 29 '18 at 20:38
  • Thank you @TheCloudFox, for now, your first option is working for the demo on a single input, going forward will explore for second also. so can you please share your social entity so I can communicate through it. Thanks for your help. – optimistic_cloud Dec 30 '18 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.