Using a <force:inputField value="{!v.account.ParentId}" /> seems to have flaws running in a Lightning Community
Issues
- Rendering: wrong/missing styles
- Link "Find more results" does not work
- After selection and save, it won't save. However the other values in the from DO save.
Compo
<aura:component controller="elfL1" implements="forceCommunity:availableForAllPageTypes,force:appHostable">
<aura:handler name="init" value="{!this}" action="{!c.init}"/>
<aura:attribute name="account" type="Account" default="{ sobjectType: 'Account' }" />
<form class="elfForm">
<force:inputField value="{!v.account.ParentId}" class="" />
<ui:button class="form-control" aura:id="button" label="Save" press="{!c.save}"/>
</form>
</aura:component>
js
init : function(component, event, helper) {
var action2 = component.get("c.getAccount");
action2.setCallback(this, function(response) {
console.log(response.getReturnValue());
component.set("v.account", response.getReturnValue());
});
$A.enqueueAction(action2);
},
save : function(component, event, helper) {
var action = component.get("c.saveAccount");
var account = component.get("v.account");
action.setParams({"account": account});
action.setCallback(this, function() {
} );
$A.enqueueAction(action);
},
apex
@AuraEnabled public static Account getAccount(){
return (Account) Database.query( ' SELECT Name,Type,Rating,ParentId FROM Account LIMIT 1 ' )[0];
}
@AuraEnabled public static Account saveAccount(Account account){
upsert account;
return account;
}
}
