Edit a customer record
In this section, you learn how to create a form using the component.form to display the fields returned from the dynamic data provider. Add an action.submit-form with a method: update that saves the changes to the record in the dynamic data provider.
Steps
Create a jig to edit data
Open the Hello-Jigx solution in Jigx Builder in VS Code, right-click on the jigs node in Explorer, and select New file.
Name the file edit-customer. Click on Default to open the skeleton YAML created by the Jigx Builder.
Give the jig a title called Edit customers and provide a description like Edit customer details.
Delete the
headerandonfocusnodes.
Add a datasource and form
You are going to use the same datasource, query, form, and form fields that you used in the view-customer.jigx file. Use the code below.
datasources:
customerInfo:
type: datasource.sqlite
options:
provider: DATA_PROVIDER_DYNAMIC
entities:
- default/customers
query: SELECT id, '$.firstName', '$.lastName', '$.email' FROM [default/customers] WHERE id = @custId
queryParameters:
custId: [email protected]
isDocument: true
children:
- type: component.form
instanceId: editCustomer
options:
children:
- type: component.field-row
options:
children:
- type: component.text-field
instanceId: firstName
options:
label: First Name
initialValue: [email protected]
- type: component.text-field
instanceId: lastName
options:
label: Last Name
initialValue: [email protected]
- type: component.text-field
instanceId: email
options:
label: Email
initialValue: [email protected] Add the submit-form action to save the data
A
submit-formaction is used to save the data from the text boxes to the SQLite database. Thesubmit formaction will automatically match theinstanceIdsof the controls on the jig and use theupdate methodto save the changes to the record in the local SQLite table with eachinstanceIdsas a property for the JSON object in the Data column. Use the submit.form action code below:
2. Your edit-customer.jigx file should resemble the code below.
Last updated
Was this helpful?