Reputation: 2617
I would like to create a single form that I can bind to a datasource in create mode and in "normal mode". The use case is that I can have an existing item in the datasource that I would like to edit, or I would like to create a new one.
I can't find a way to dynamically switch the datasource mode before opening the form. It seems that 2 forms are required to accomplish this.
Any suggestions on how to accomplish this?
Upvotes: 0
Views: 144
Reputation: 6347
It is possible to reuse form fields, but you'll still need at least two forms (containers). The idea is to create a page fragment with datasource derived from some model:
then you can add this page fragment to form (container) and override datasource.
Normally you would choose between normal mode:
@datasource.item
...and create mode:
@datasource.modes.create.item
You can find complete code sample in Project Tracker template and learn more about create mode in docs:
https://developers.google.com/appmaker/models/datasources#create_mode_datasource
Upvotes: 1