0

I am trying to make one of my input fields conditionally required based on a checkbox value of false. Is this possible using a standard 'required' attribute in Lightning/Aura? The below doesn't seem to be working for me using the required attribute.

<aura:if isTrue="{! rt.Name == 'RT'}">

<lightning:inputField aura:id="Budget__c" fieldName="Budget__c"
 value="{!v.Package.Budget__c}" required ="{!v.Package.Checkbox__c == false}"/> 

</aura:if>

2 Answers 2

1

You can add required attribute based with true/false value.

If your field value is Boolean v.Package.Checkbox__c then directly add your values.

Example:

<lightning:inputField aura:id="Budget__c" fieldName="Budget__c"
 value="{!v.Package.Budget__c}" required="{!v.Package.Checkbox__c}"/> 

Ref : https://developer.salesforce.com/docs/component-library/bundle/lightning:inputField/documentation

0
<aura:if isTrue="{! rt.Name == 'RT'}">

<lightning:inputField aura:id="Budget__c" fieldName="Budget__c"
 value="{!v.Package.Budget__c}" required ="{!v.Package.Checkbox__c == false}" disabled="false" required = "true"/> 

</aura:if>
1
  • Duplicate required Attribute is not good
    – A.K.
    Sep 27, 2023 at 6:31

You must log in to answer this question.

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