With the release of Spring '16 there appear to be significant improvements to the force:inputField components especially for the lookup fields.
We are trying to use them in our application, but are having issues generating them dynamically. In our use case the user may define a set of fields that they want displayed for their form. This means we need to generate a list of inputs based on a dynamic set of fields.
Here is a statically defined example of how we can show the Custom_Acccount_Lookup__c field.
<aura:attribute name="contact" type="Contact" default="{ 'sobjectType': 'Contact' }"/>
<force:inputField value="{!v.contact.Custom_Account_Lookup__c}"/>
However how can we generate this same code if the field we want displayed was user defined? The code below obviously doesn't work, but is it possible to achieve this some other way? We have also tried to generate the component in the controller but run into similar issues when passing in the value.
<aura:attribute name="contact" type="Contact" default="{ 'sobjectType': 'Contact' }"/>
<aura:attribute name="fieldToShow" type="String" default="Custom_Account_Lookup__c"/>
<force:inputField value="{!v.contact[v.fieldToShow]}"/>
We are starting to suspect that there is some pre-processing of the component code before it renders. Upon code inspection the component actually generated is a force:inputLookup which is not one that we can create but apparently Salesforce uses to display the lookup field.