I have a rather complex form, and would like to make sure it works both in editing and as a "new record" form.
The form's submit is actually prevented, and JSON is actually sent over. However, this is besides the point.
Also, this.record
is assigned on load (for editing) and an empty object for new records.
render () {
return html`
<form>
<input type="text" .value="${this.record.description}">
<input type="text" .value="${this.record.remarks}">
</form>
`
}
The idea is that if the form is rendered, and there is data in this.record, it will have the data pre-populated.
This assumes that this.record doesn't change under the form's butt -- if it does, the user input WILL be overwritten.
Is what I described above best practice? Or is it best NOT to use .value=
and assign the fields by hand on load?