4

I am struggling to understand the need to have a force:recordData and a lightning:recordEditForm when both do almost similar things. Is one better than the other? I know lightning:recordEditForm supports lightning:inputField which could make life easier for some, but I am certain there are other differences. Care to shed some light on this?

1 Answer 1

10

Neither one is necessarily "better" than the other; they're both tools to be used. The main difference between the two is that one is intended for scripted access to records (force:recordData), while the other is for providing a UI to edit a record (lightning:recordEditForm). Use the former if you just need lightweight access to a record, and the latter if you need to provide a user interface that resembles a standard record edit form.

5
  • The latter also provides an easy way to access what apex:inputField use to be. I sometimes find myself throwing away the actual save/submit methods because I just needed the SObject field bind (and subsequently manually finding the value via aura:id).
    – tsalb
    Commented Jun 29, 2018 at 18:17
  • @tsalb That's a good point, but I consider that more of a workaround; they really need to have similar functionality on the force:recordData object or something else entirely.
    – sfdcfox
    Commented Jun 29, 2018 at 18:22
  • maybe one day, they will let us use lightning:inputField standalone. wishful thinking.
    – tsalb
    Commented Jun 29, 2018 at 18:28
  • 2
    lightning:recordEditForm internally uses Lightning Data Service for DML
    – Praveen
    Commented Jun 30, 2018 at 4:07
  • 1
    @Praveen That makes sense, of course. Why invent something new when you have what you already need? That's the power of Lightning Components, making things reusable.
    – sfdcfox
    Commented Jun 30, 2018 at 4:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .