Lightning input field lwc - How can I make it not required?
I am using a lightning-record-edit-form as shown below
onchange={handleAccountFieldChange}>
According to https://www.lightningdesignsystem.com/components/form-element/ , the lightning-input-field control value is supposed to be required only if we add the required attribute to it. Even though I do not have the required attribute set on the lightning-input-field , it is still being displayed as a required field. How can I fix this?
You are confusing lightning-input with lightning-input-field. lightning-input-field lwc will follow the field's configuration (required or not based on how it was created under setup > object > field(s)) and is dependent of the record-edit-form. It uses the record-ui API to determine a number of things, including if it is required or not. vs lightning-input which does not, as it is "standalone" If you want to make it "not required" you will ahve to modify the field settings directly, vs adding a required attribute if you were using a lightning-input field