Building Apps with Jigx
...
Jigs (screens)
Forms

Updating a Record

3min
learn how to update an existing record using a form populating a form with initial values before updating the record, we have to bind the existing record to the form for that purpose, the form component has an option called initialvalues which can be used to set all form fields to the current values at once in this example, we will use an input parameter recordid (see inputs & outputs docid\ fu7mlkg30usqg7ziqwsml ) to query a data record from the dynamic data table and then bind that record to the initialvalues of our form please note the optional isdocument option of our datasource will ensure that only the first record will be returned by our query as a json object update form jigx title update form description my first update form by jigx type jig default datasources employee detail type datasource sqlite options provider data provider dynamic entities \ entity default/form query select id, '$ firstname', '$ lastname', '$ email', '$ phone' from \[default/form] where id = @recordid queryparameters recordid =@ctx jig inputs recordid isdocument true children \ type component form instanceid simple form options initialvalues =@ctx datasources record children \ type component text field instanceid firstname options label first name \ type component text field instanceid lastname options label last name \ type component email field instanceid email options label email keyboardtype email address \ type component number field instanceid phone options label phone number keyboardtype number pad updating the record in this section, we will gonna have deep look at how you can update your records in the database or delete them with jig form update with submit form action another way to update data is by the submit form action we put the id of the record which we want to update update form execute entity action for the update form, we will use the previous from that we just created and modify it we change the method in our action execute entity from save to update, under data we add a new row with id =@ctx components id state value , also we need to create a new entity field for id, and for every component what we have we must add new rows with initialvalue your update form jigx file should resemble the code below update form jigx title update form with execute entity action description my first update form by jigx type jig default actions \ children \ type action execute entity options title update form provider data provider dynamic entity default/form method update data id =ctx jig inputs recordid firstname =@ctx components firstname state value lastname =@ctx components lastname state value email =@ctx components email state value phone =@ctx components phone state value children \ type component form instanceid simple form options children \ type component text field instanceid firstname options label first name initialvalue =@ctx datasources employee detail firstname \ type component text field instanceid lastname options label last name initialvalue =@ctx datasources employee detail lastname \ type component email field instanceid email options label email keyboardtype email address initialvalue =@ctx datasources employee detail email \ type component number field instanceid phone options label phone number keyboardtype number pad initialvalue =@ctx datasources employee detail phone