Adding new records to a Data List using forms
With Justinmind, you can add new records to a Data List using forms. In this example, we’ll create a new flight details input screen. When the user inputs their new flight details and clicks a button, information about their flight will be added to display in a Data List.
To add new records to your Data List, follow these steps:
- Create a Data Master with the following fields: Airline, Departing to, Flight, Scheduled, Terminal, Gate, Status.
- Draw the form by dragging some Text widgets and Input Text Fields to the Canvas. Alternatively, drag your Data Master to the Canvas from the Data Masters palette, which will automatically create a form.
- Drag a Button to the Canvas, label it “New” and place it below the input form you just created.
- Create two additional screens in your prototype, naming them “Confirmation Page” and “Flight List”.
- From the Variables palette, create a variable for each of the Input Text Fields you have on the screen, leaving the default value empty.
- Drag each Input Text Field to its respective variable. This will create an “On Page Unload” + “Set Value” event, and will set the variable’s value to whatever’s entered in its respective Input Text Field. Repeat this until each Input Text Field has an “On Page Unload” + “Set Value” event.
- Drag the “New” Button to the “Confirmation” screen in the Screens palette, which will create an “On Click” + “Link To” event.
- On the “Confirmation screen”, we’ll display the values stored in the variables in Text elements. We’ll also have a button that, once clicked, creates a new record in the Data Master with all the new flight information. To create this screen, drag as many Text widgets to the screen as the variables you have, i.e. seven, to the Canvas. Then, drag a Button to the Canvas and place it below the Text elements.
- Drag each variable from the Variables palette to the Text element where you want it displayed. This will create an “On Page Load” + “Set Value” event, which will display the value stored in the variable in each Text element.
- Select the Button, go to the Events palette and add an “On click” + “Data Master Action – New” event. In the Calculated Expression builder, drag the variables for each Data Master field to each corresponding space in the expression.
- Next, drag the Button to the “Flights List” screen to create an “On Click” + “Link To” event.
- Lastly, go to the “Flights List” screen and drag a Data List to the Canvas and select the Data Master you’ve created.
That’s it! You can now click “Simulate” and try adding a flight to the list.
You can download our example here.