The lightning-record-edit-form has a documented submit
method that I assume can produce similar behavior to a click on a nested submit button. But I can't find any examples of this.
The documentation describes a fields
argument for the submit
method of:
Submits the form using an array of record fields or field IDs. The field ID is provisioned from @salesforce/schema/. Invoke this method only after the load event.
When no argument is supplied to submit
, features like required field validation does not work. I'm not in a position to test right now so am wondering:
- If the fields are hard-coded as the
submit
argument, does the expected behavior result? - Can the field names specified in the nested
lightning-input-field
elements be programmatically obtained? (I note thatlightning-record-edit-form
has afield-names
property but that is documented as "Reserved for internal use. Names of the fields to include in the form.".)
fields
seems to be the event parameter that contains all the fieldssubmit
method to call from outside oflightning-record-edit-form
but the behavior is inconsistent with including an input or a button inside of the component. 1) the field validations do not fire and 2) if you have a submit handler (onsubmit
) it isn't called! Additionally, there's no mechanism to grab the fields from alightning-record-edit-form
unless you use a querySelector or the fields are set dynamically from the JS side of the component.