I'm trying to get lightning: input field value in my component controller but its either giving me undefined value if I don't define a default value in my attribute or giving me default value.


<aura:component >
    <aura:attribute name="booleanvalue" type="boolean" default="false"/>

    <lightning:input type="checkbox" value="{!v.booleanvalue}" label="Test Checkbox"/> 

    <lightning:button label="Save" onclick="{! c.handleSave}"/>


    handleSave : function(component, event, helper) {
        console.log('>>> save method... '+component.get("v.booleanvalue"));

Try using:

<lightning:input type="checkbox" checked="{!v.booleanvalue}" label="Test Checkbox"/> 
  • With boolean attribute its working but if I use object.CustomField__c, I'm getting Uncaught TypeError: Cannot read property 'CustomField__c' of null error – sfdc Jan 18 at 22:56
  • How are you getting the value for the CustomField__c ? It is a boolean data type, right? – Carlos Naranjo Jan 18 at 22:58
  • Yes, its boolean data type and that's how I have declared the attribute <aura:attribute name="customObject" type="CustomObject__c" /> – sfdc Jan 18 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.