No application would be complete without the ability to show and edit
a single record. You can implement this functionality using a Form
To quickly design screens to create, show
and edit a single record.
As an example assume you have an application to manage contacts and
that you already have a Contact entity created in that application.
To show and edit a Contact record:
- Create a web screen, e.g. ContactDetail
- Add an input parameter of data type Contact Identifier, e.g. ContactId
- Add an aggregate to the preparation to fetch this contact from
- Add a Form widget to the screen and bind it to the output of the
aggregate in the preparation
- Drag and drop the Contact entity into the Form.
- Add a 'Save' button to the form and use the UpdateContact entity
action to store the changes performed by the end-user in the database.
Creating a Single Record on the same page
With a few changes you can transform this page to allow creating contacts.
The steps are as follows:
- Set the 'ContactId' screen input parameter as non mandatory.
- Add a If widget to the screen to conditionally show the page
title either as the contact name or as 'New Contact', depending on
the 'ContactId' parameter having a value other than NullIdentifier
- In the 'Save' screen action replace the UpdateContact
entity action with the CreateOrUpdateContact
the Form Widget | Form
Widget Runtime Properties | About