Use same form for Add and Edit

Is there any way to use the same form to add a record an also to edit it a record pulled from a database via serverconnect? It seems redundant to have an essentially identical form twice on the page (as modals).
Thanks.

Hi @Heather_Mann
Yes. that is possible. Depends on how are you filtering your update record data (using an url variable, or using some variable on the page) you can add a condition step in your server action.

Usually you have some hidden field, holding the updated record ID which is sent as a $_POST variable to your server action. With the condition step check if this $_POST variable has a value or not, so if it has a value - run the update step, otherwise run insert.

5 Likes

Illustrating what Theodor said

2 Likes

Awesome!! That’s just what I wanted. Thanks Teodor and alsdigital!

2 Likes

Done anyone have a tutorial of this?
Using one form to insert and edit.
Providing just a bit more detail of what Alsdigital posted…

2 Likes