Skip to content

Instantly share code, notes, and snippets.

@lfreeland
Created February 24, 2018 14:55
Show Gist options
  • Select an option

  • Save lfreeland/b99eda78d472420c82ac198a9266a223 to your computer and use it in GitHub Desktop.

Select an option

Save lfreeland/b99eda78d472420c82ac198a9266a223 to your computer and use it in GitHub Desktop.
Lightning Field Set Form V2 Controller
({
init: function(cmp, event, helper) {
console.log('FieldSetFormController.init');
var fieldSetName = cmp.get('v.fieldSetName');
var sobjectName = cmp.get('v.sObjectName');
var recordId = cmp.get('v.recordId');
if (!fieldSetName) {
console.log('The field set is required.');
return;
}
var getFormAction = cmp.get('c.getForm');
getFormAction.setParams({
fieldSetName: fieldSetName,
objectName: sobjectName,
recordId: recordId
});
getFormAction.setCallback(this,
function(response) {
var state = response.getState();
console.log('FieldSetFormController getFormAction callback');
console.log("callback state: " + state);
if (cmp.isValid() && state === "SUCCESS") {
var form = response.getReturnValue();
cmp.set('v.fields', form.Fields);
}
}
);
$A.enqueueAction(getFormAction);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment