I want to conditionally render one of the fields from recordEditForm. I've already done with attributes that are outside of form, but this time I want to bind the directly.

Thinking something like this along the lines:

<aura:attribute name="myBooleanAttribute" type="Boolean" access="private"/>
                    <lightning:inputField fieldName="SomeBoolean__c" value="{!v.myBooleanAttribute}"/>
                    <lightning:inputField class="{!v.myBooleanAttribute?'':'slds-hide'}" fieldName="Move_in_Date__c"/>

However this doesn't seem to bind them both ways...

  • Can you clarify a bit as what issue you are facing?
    – Jayant Das
    Commented Mar 20, 2019 at 20:55
  • I want to render one field based on DB state or when user clicks on checkbox (SomeBoolean__c). It seems recordEditForm can only push data into inputField but I am looking for workaround.
    – dzh
    Commented Mar 20, 2019 at 21:15

1 Answer 1


Here's one way you can achieve it by utilizing onchange event on your boolean input field. The value attribute will not have an effect here, it will just override the value of your input field.

So to get this done, you will need to:

  • Remove the value attribute
  • Introduce an onchange and assign an aura:id to the field
  • Utilize aura:if to re-render other field based on the selection

The component then looks as:

<lightning:inputField aura:id="chkbox" fieldName="SomeBoolean__c" onchange="{!c.onCheckBoxChange}"/>

<aura:if isTrue="{!v.myBooleanAttribute}">
    <lightning:inputField fieldName="Move_in_Date__c" />

And then in the JS controller, update the attribute's value to be re-rendered

onCheckBoxChange : function(component, event, helper) {

    // will reset the value of the attribute to re-render the input field on component

    component.set("v.myBooleanAttribute", component.find("chkbox").get("v.value"));
  • Sorry, that doesn't work on init when SomeBoolean__c is already true.
    – dzh
    Commented Mar 21, 2019 at 0:15
  • Just set the attribute on onload of the record edit form and it will work.
    – Jayant Das
    Commented Mar 21, 2019 at 0:18
  • Yep thats what I did. Also used conditional slds-hide class rather than aura:if.
    – dzh
    Commented Mar 21, 2019 at 0:43
  • Absolutely there could be other ways for sure but based on your question the approach I mentioned works too.
    – Jayant Das
    Commented Mar 21, 2019 at 0:52

You must log in to answer this question.

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