Last active
April 7, 2019 16:32
-
-
Save gminero/0b55cba37dd09644cb36b5a95c62b2b2 to your computer and use it in GitHub Desktop.
custom form using slds blueprints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" > | |
<aura:attribute name="size" type="String" default="6" /> | |
<aura:attribute name="label" type="String" default="Status" /> | |
<aura:attribute name="fieldValue" type="String" default="" /> | |
<aura:attribute name="auraId" type="String" default="aField" /> | |
<aura:attribute name="isReadonly" type="Boolean" default="true" /> | |
<div class="slds-blueprint"> | |
<lightning:layout multipleRows="true"> | |
<lightning:layoutItem padding="around-small" size="{!v.size}"> | |
<div class="slds-form-element slds-form-element_edit slds-form-element_readonly slds-hint-parent"> | |
<span class="slds-form-element__label">{!v.label}</span> | |
<div class="slds-form-element__control"> | |
<input aura:id='editinput' class="slds-form-element__static" value="In Progress" readonly="{!v.isReadonly}"/> | |
<button class="slds-button slds-button_icon" title="Edit: Status"> | |
<lightning:buttonIcon iconName="utility:edit" variant="bare" onclick="{! c.handleClick }" alternativeText="edit" /> | |
<span class="slds-assistive-text">Edit: Status</span> | |
</button> | |
</div> | |
</div> | |
</lightning:layoutItem> | |
</lightning:layout> | |
</div> | |
<div class="recordEditForm sldshide"> | |
<lightning:recordEditForm aura:id="recordEditForm" | |
recordId="{!v.someRecordId}" | |
onload="{!c.handleLoad}" | |
onsubmit="{!c.handleSubmit}" | |
onsuccess="{!c.handleSuccess}" | |
objectApiName="Account"> | |
<lightning:messages /> | |
<!--HIDDEN FIELDS TO USE THE INTERFACE API AND ASSING FIELD VALUES ON FORM SUBMIT --> | |
<lightning:inputField fieldName="Name" value="{!v.accname}"/> | |
<lightning:inputField fieldName="OwnerId" value="{!v.accowner}"/> | |
<lightning:inputField fieldName="Rating" value="{!v.accrating}"/> | |
<div class="slds-m-top_medium"> | |
<lightning:button disabled="{!v.disabled}" variant="brand" type="submit" name="save" label="Save" /> | |
</div> | |
</lightning:recordEditForm> | |
</div> | |
</aura:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.THIS .slds-form-element__static{ | |
border: 0; | |
outline: 0; | |
background: transparent; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
handleLoad : function(component, event, helper) { | |
//Get field values you need | |
const someFieldValues = JSON.stringify(event.getParam("recordUi")) | |
}, | |
handleSubmit: function(component, event, helper) { | |
}, | |
handleSuccess: function(component, event, helper) { | |
}, | |
handleClick:function(component, event, helper) { | |
component.set('v.isReadonly', false); | |
var toFocus = component.find("editinput").getElement(); | |
toFocus.focus(); | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment