I am trying to set checkbox value as default. Below is the code.

 <label class="slds-form-element__label">Is Active</label>
    <force:inputField  value="{!v.Opp.Active__c}" />

Can someone let me know how to set.

  • As you are using force:inputField try to set the checkbox field default value set to checked instead of unchecked that must show you checked it on the new record. It's just a guess not sure it will work or not. Commented Feb 6, 2019 at 12:42

3 Answers 3


The place to populate default data values is either in your declaration of your <aura:attribute>:

<aura:attribute name="contact" type="Contact" 
           default="{ 'sobjectType': 'Contact', 'LastName': 'Schmoe' }"/>

or in your controller, if, for example, you wish to populate data from the server into an attribute and then make changes, or dynamically create a new object:

     doInit : function(component, event, helper) {
        var action = component.get("c.getContact");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                let cont = response.getReturnValue();
                cont.LastName = "Schmoe";
                // Add a default value (not persisted to the database!)
                component.set("v.contact", cont);

if opp is the attribute name, then do this in your init function

var oppDefault = cmp.get("v.opp");


Note : Syntax might not be accurate, you get the idea that defaulting should be in attribute default parameter for strings etc, or in the init function for objects



I think you can set it in doInit method. Below is the sample code.

Code in Component

<force:inputField value="{!v.Opp.Active__c}">

Code in controller

doInit : function(cmp, event, helper){
    var opp = cmp.get("v.Opp");
    opp.Active__c = true;
    cmp.set('v.Opp', opp);
  • I have to make Active__c = true when opp.Type = 'New'. If opp.Type = 'Old' then Active__c=false.
    – SFDC Guest
    Commented Feb 6, 2019 at 13:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .