If a logged-in visitor to your Site has submitted a WebApp Item, they can now edit it too.
Most WebApps, including those created by the Admin and those created by visitors who are not logged in will not store the ID of a creator
.
However, any WebApps created Front-End by a logged in User will store their creator's ID in the creator
field.
In this example we create a variable by hard-coding a specific User ID.
You can now access the following fields inside a WebApp Layout:
{{this.creator.id}}
{{this.creator.name}}
{{this.creator.first_name}}
{{this.creator.last_name}}
{{this.creator.created_at}}
Under default settings, only a WebApp owner can see and also submit the edit form. A WebApp gets an owner when a user is logged in and submits the original WebApp create form. Their User ID is stored in the user_id field against the webapp.
It is possible to modify the owner of a WebApp in the Siteglide Admin.
It is also possible to set the "Anyone can edit" setting to true in the Siteglide admin in the "View Table" area for that WebApp.
Setting this to true means that default edit protections are removed for that WebApp on the front-end. You will then be responsible for writing your own Liquid code to wrap around the form if you wish to set custom Secure Zone permissions.
You could of course combine both of these features- creating a link to the same page including the creator_id as a query parameter and then filtering by that ID using context.params
to fetch the ID from the URL.
Unlike the "Add" Form, the Front End WebApp Edit Form must be linked to the specific WebApp Item it will Edit. This means you can only output the Form inside a WebApp Detail or List Layout file.
To include the Edit Form inside a WebApp Layout, add the Liquid tag:
Parameters:
layout
- Optional - Choose the name of your Layout file
The Edit Form will work if you use the same Layout as you used for your add Form.
However, you may wish to use an alternative Layout so you can add some additional features.
As you're including the Edit Form inside a WebApp Item, you have access to the WebApp fields that are inherited from the WebApp Layout.
One example might be adding a Title to the Form which dynamically references the WebApp Item: <h3>Edit {{this.name}}</h3>
Another example might be displaying the creator's name: <h4>By {[this.creator.name}}</h4>
In a Form Layout, we use the form_builder
variable to dynamically add the correct name
Attribute to inputs. You can use this to output the pre-filled value; instead of the name property, output the value property.
For this example WebApp field:
...you can use the name field and replace .name
with .value
to add a value
attribute: