everybody. I have lightning component on which I need to display some fields. Set of fields are dynamic and I`m displaying it using aura:iteration (I have a wrapper with name and label of field, its value and type). But I do not know, which tag use for displaying field, because it may be checkbox or date or anything else. Maybe, somebody already had such problem and can help me to solve this problem. Thank you for help.

  • you have to create component dynamically based on datatype of the fields.check this answer out it might help you. – Praveen Oct 5 '16 at 17:02

Use force:inputField or force:outputField depending on your need. SF will take care of outputting the correct type

A component that provides a concrete type-specific output component implementation based on the data to which it is bound. Represents a read-only display of a value for a field on a Salesforce object. This component respects the attributes of the associated field and how it should be displayed. For example, if the component contains a date and time value, then the default output value contains the date and time in the user's locale. Bind the field using the value attribute and provide a default value to initialize the object.


  • out of curiosity how did you bind object fields since sobject[dynamicField] syntax does not work? – Kiran Machhewar Oct 11 '16 at 11:42
  • @KiranMachhewar this answer is incomplete. You have to use the input/output field in conjunction with a recordViewForm component – TemporaryFix Aug 6 '19 at 19:41
  • 1
    @Programmatic - You are incorrect. The component on the inputField using the force namespace only requires an attribute of the Subject type you are using. (developer.salesforce.com/docs/component-library/bundle/…) Appreciate the downvote though! – Eric Aug 6 '19 at 19:49

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