Is it possible to make a <lightning-input-field>
where field-name
is required (such as Contact.LastName
) not required on the UI?
I would like the field to not kick in validation rules (client ones) and not to have the required
styling once I submit, but it still happens when setting required
to false
.
Sample code:
<lightning-record-edit-form
object-api-name="Contact"
form-class="slds-grid slds-wrap slds-m-left--xx-large slds-m-bottom--medium"
onsubmit={handleSearch}
>
<template for:each={searchFields} for:item="field">
<div key={field.name} class="slds-col slds-size_1-of-4">
<lightning-input-field field-name={field.name} value={field.value} required={isFalse}></lightning-input-field>
</div>
</template>
<div class="slds-col_bump-left slds-p-top--large">
<lightning-button class="slds-p-right--large" label="Search" type="submit"></lightning-button>
</div>
</lightning-record-edit-form>
In the JavaScript file:
get isFalse() {
return false;
}