I'm building out a question answer component where certain answers will have specific input types and it would be nice to set some key parameters of the input field yet still use the lightning:recordEditForm component. In particular, I am branching off between a text input or a numeric input where the numeric field has min/max values. I can add those parameters to an lightning:inputField but they dont do anything. I can use a lightning:input an the min max works, but it doesnt save. Any idea on how to mix the two?
<lightning:recordEditForm aura:id="caseQuestionAnswer"
objectApiName="Case_Question_Answer__c"
onsuccess="{!c.handleSuccess}"
recordId="{!v.question.Id}">
<aura:if isTrue="{!empty(v.question.Application_Question__r.Min__c)}">
<lightning:inputField fieldName="Answer__c" aura:id="caseQuestionAnswer"/>
<aura:set attribute="else">
<lightning:input type="number" fieldName="Value__c" aura:id="caseQuestionValue" min="{!v.question.Application_Question__r.Min__c}" max="{!v.question.Application_Question__r.Max__c}"/>
</aura:set>
</aura:if>
<lightning:button aura:id="submit" type="submit" label="Save Answer" class="slds-m-top_medium"/>
</lightning:recordEditForm>
Best Answer
The best thing to do for your specific scenario is to 'hide' the
lightning:inputField
and add alightning:input
, similar to what Uwe Mentioned, however, you dont really need to do anything with thelightning:inputField
, you will simply need it to load the data associated to it and to be able to Save the field value on form submission. For Example:When you submit your form, use the
onsubmit
event to fetch the field value form the input field (not the lighntning:inputField) and assign it to the fields object: