1

In a Lightning Components Developer Guide there are two inputFields - [one] in a force namespace and a [second] in a lightning namespace. Looks like both of them serve the same purpose (being an input field) but their functionality just differs a bit.

I can undestand a reason why there are two types of input fields for both the Lightning Components and Visualforce Pages since they are parts of kinda different frameworks, but can someone explain me why it couldn't be one inputField for a Lightning and they decided to split it on two and put into different namespaces?

2

tl;dr use lightning:inputField and always choose the lightning namespace components when possible.

The lightning namespace components are the next generation of components for Lightning. These components:

  • Use Salesforce Lightning Design System (SLDS) so will always track the latest look and feel from Salesforce including theming/branding/etc customizations of the org.
  • Use Lightning Data Service (LDS) so will run faster and always be in sync with other LDS-based components.
  • Are optimized for runtime performance.
  • Have improved accessibility built in.

You'll find more capabilities coming to the lightning namespace components with each release.

There are some backwards-compatibility challenges with converging the components from force and lightning. For reasons like this you'll see the force components will continue to exist.

You should also check out the new Lightning Component library at https://developer.salesforce.com/docs/component-library. I find it much easier to use than the other doc site you linked.

4

force:inputfield does not have SLDS baked into it .So there is no out of box styling for the inputfield . Apart from that does not work properly .Specially does not work inside aura:iteration and does not work with lookup fields .

lightning:inputField is a revised version and includes SLDS out of box and also is supposed to be better performant .This uses salesforce UI API under the hood .

2

(in the specific case of input fields) They don't really serve the same purpose,

A component that provides a concrete type-specific input component implementation based on the data to which it is bound.

So, it cant really stand on its own, additionaly, it is not styled wiht the SLDS. (same goes with all the components in this namespace) contrary to the Lightning namespace components, which have the Lightning Design System styling embeded within them, they also handle accessibility, real-time interaction, and enhanced error messages. (as per the documentation)

For lightning development, you will always want to leverage components under the lightning namespace.

I also believe that the force namespace was released before the lightning namespace, you might notice that many lightning namespace components require you to use more recent api versions.

there are a number of other components that serve different purposes in each, high level, for lightnig components, you will want to stick to the lightning namespace

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.