You need to sign in to do that
Don't have an account?
fiona gentry
How To Make Level_2 and Level_3 as ReadOnly in Custom Salesforce Lightning component
How To Make Level_2 and Level_3 as ReadOnly in Salesforce Custome Lightning component
I have a controller which has 3 text boxes ,now i want level2 and level3 as ReadOnly ,how can i do that
Here is custom component currently which has editable Level2 and Level3,my need is to make these 2 fields as read only
here is the .cmp file
Your response is highly appreciated
Regards,
Fiona
I have a controller which has 3 text boxes ,now i want level2 and level3 as ReadOnly ,how can i do that
Here is custom component currently which has editable Level2 and Level3,my need is to make these 2 fields as read only
here is the .cmp file
<aura:component implements="force:hasRecordId,force:appHostable,flexipage:availableForAllPageTypes,force:lightningQuickAction" access="global" controller="Stack"> <aura:attribute access="private" type="List" name="selection" default="[]"/> <aura:attribute access="private" type="List" name="errors" default="[]"/> <lightning:card title="ERT Case Type"> <lightning:recordEditForm aura:id="myForm" objectApiName="ERT_Case_Type__c" onsubmit="{!c.onSubmit}" onsuccess="{!c.onSuccess}"> <lightning:messages /> <c:Lookup selection="{!v.selection}" onSearch="{!c.lookupSearch}" onSelection="{!c.useSelected}" errors="{!v.errors}" label="Search" placeholder="Search ERT Case Types Data"/> <lightning:inputField aura:id="Level_1__c" fieldName="Level_1__c" /> <lightning:inputField aura:id="Level_2__c" fieldName="Level_2__c" /> <lightning:inputField aura:id="Level_3__c" fieldName="Level_3__c" /> <lightning:button class="slds-m-top_small" variant="brand" type="submit" name="save" label="Save" /> </lightning:recordEditForm> </lightning:card> </aura:component>here is .js file
({ lookupSearch : function(component, event, helper) { // Get the lookup component that fired the search event const lookupComponent = event.getSource(); const serverSearchAction = component.get('c.search'); lookupComponent.search(serverSearchAction); }, useSelected: function(component, event, helper) { const selection = component.get('v.selection'); const errors = component.get('v.errors'); if (selection.length) { if(errors.length){ // Clear errors, if any component.set('v.errors', []); } let levels = selection[0].subtitle.split('; '); component.find('Level_1__c').set('v.value', levels[0]); component.find('Level_2__c').set('v.value', levels[1]); component.find('Level_3__c').set('v.value', levels[2]); }else { // Somebody "selected" empty option = cleared the search box component.find('Level_1__c').set('v.value', ''); component.find('Level_2__c').set('v.value', ''); component.find('Level_3__c').set('v.value', ''); } }, onSubmit: function(component, event, helper) { debugger; event.preventDefault(); // stop the form from submitting var fields = event.getParam('fields'); fields.Case__c = component.get('v.recordId'); // link to "this" Case component.find('myForm').submit(fields); }, onSuccess: function(component, event, helper){ var toastEvent = $A.get("e.force:showToast"); toastEvent.setParams({ "title": "Success!", "message": "Case Type saved OK, refreshing", "type": "success" }); toastEvent.fire(); $A.get('e.force:refreshView').fire(); // reload page } })
Your response is highly appreciated
Regards,
Fiona
However, I have seen a few questions in the past around the community saying it actually does not work. I recommend giving a try, if it doesn't help you should go with the disabled attribute instead. See the following posts
readonly property of lightning:input not working
Lightning inputText component readonly
Let me know if this helps, if it does, please close the query by marking it as solved. It may help others in the community. Thank You!