Table of Contents
You may allow logged-in users to edit a single entry, all of their submitted entries, or all entries submitted by other users as well. Insert an edit link on any page, post, or View to lead users back to the form to edit or update an entry on the front-end.
Follow these steps to set up your form for editing.
- Go into edit your form and click the "Settings" tab.
- Check the "Limit form visibility and submission" box. Select which user role you would like to allow access to this form. All higher user roles will also have access to the form. If you want logged-out users to be able to fill in the form as well, do not check this option. Just remember that logged-out users cannot edit entries.
- Check the "Allow front-end editing of form submissions" box. Determine which user role can edit their own submissions and which user role can edit responses submitted by other users.
- If you would like to limit users to one entry, check the "Limit number of form submissions" box and select "Logged-in Users". After a user submits an entry, they will be able to edit the entry when they return to the form.
- If you would like to allow users to submit multiple entries, you need to add an edit link or a list of previous entries which will allow users to select an entry to edit.
- Add a list of the user's previously submitted entries to a page or post with this shortcode: [frm-entry-links id=x] where x is the ID number for this form. If you place this on a different page from your form, add page_id=y, where y is the id of the page that contains your form. This shortcode will default to a list of entry creation dates. When the user clicks on one of these dates, they will be able to edit that entry. For customization of the entry list, see how to display a List of Entries.
- Add an edit link to a page or post with this shortcode: [frm-entry-edit-link id=x label="Edit" page_id=2]. Add an edit link to a View with this shortcode: [editlink location="front" label="Edit" page_id=x]. Replace 'x' with the id of the page that holds the form. These shortcodes and their customizations are described in more detail below.
Add an Edit Link
Insert an edit link on any page, post, or View in order to allow users to easily edit or update entries. Before an edit link will work correctly, you must set up your form to allow editing.
Please note: The edit link will only appear for those authorized to edit the entry. Editing permissions can be modified on your form's Settings page.
There are two forms of this shortcode. The first is for use in pages, posts, and widgets and the second is for use in Views.
In pages, posts, or widgets
[frm-entry-edit-link id=x label="Edit" page_id=y]
‘x’= ID of the entry to be edited, or "current" (see id in the parameter list below for more info)
‘y’= ID of the page where the form is published (see page_id in the parameter list below for more info)
[editlink location="front" label="Edit" page_id=y]
'y' = ID of the page where the form is published
The following parameters can be used with frm-edit-entry-link and the editlink shortcode.
- id – The ID of the entry to edit (not required for editlink). This ID can be found by going into your form and clicking on "Entries". The furthest left column typically contains the entry IDs. If you are inserting this link directly on a post page that was created by Formidable, you can use id="current" to dynamically get the ID of the entry from the post being viewed.
- page_id – The ID of the page where the form is published. You can find the ID of a page by going into edit the page and looking in the address bar as shown below. If the page_id is not specified, this defaults to the current page ID.
- label – Change the text of the edit link which is "Edit" by default. Use label=0 to remove any HTML from the front-end link. Usage: [frm-entry-edit-link id=x label="Edit" page_id=y]
- class – If you are using the label parameter, you can add an HTML class to the edit link to add styling. Usage: [frm-entry-edit-link id=x label="Edit" class="my_edit_class" page_id=y]
- form_id (not for editlink) – The ID of the form which holds the entry to edit. Including this parameter will slightly decrease processing time. Usage: [frm-entry-edit-link id=x label="Edit" form_id=y page_id=y]
- location (for editlink only) – By default, the edit link sends the user to the back-end of the entry to edit. If you would like to send the user to the front-end of the entry, include location=”front”. Usage: [editlink location="front" label="Edit" page_id=2]
- prefix – If you would like to edit the entry in-place (as seen in the help desk), use the prefix parameter. In order to use the prefix parameter, you must add a div around your content which has an id like <div id="frm_container_253"> where 253 is the entry ID. In a View, this would be <div id="frm_container_[id]">. When "Edit" is clicked, the prefix parameter will replace everything inside of this div with the form to edit. The edit link must go outside of this containing div for the "Cancel" link will show when editing. This may be how it would look in a View:
[frm-entry-edit-link id=x label="Edit" cancel="Cancel" prefix="frm_container_"] <div id="frm_container_[id]"> Content here </div>
The text in red must match in order for prefix to work properly.
- cancel – If using the prefix parameter, you can change the label on the cancel link. By default, the link will say "Cancel". Usage: [frm-entry-edit-link id=x label="Edit" cancel="Cancel" prefix="frm_container_"]
echo FrmProEntriesController::entry_edit_link(array('id' => x, 'label' => 'Edit', 'page_id' => y));
Replace 'x' with the ID of the entry to edit and replace 'y' with the ID of the page where the form is published.
Insert a Link to Update a Field
If you would like to provide a link to your users which allows them to update a single field without returning to the form, see Insert a Link to Update a Field.
Edit In-Place and Delete with Ajax
If you would like to use an edit link to edit in-place and a delete link to delete an entry with Ajax, you will need to set up your content like this:
<div id="frm_del_container_[id]"><div id="frm_edit_container_[id]"> Majority of your content will go here. This is where the form will appear when you hit the Edit link. </div> [editlink location="front" page_id=x label="Edit" prefix="frm_edit_container_"] [deletelink page_id=x label="Delete" prefix="frm_del_container_"] Some additional content may go here. </div>
The outer frm_del_container_[id] div holds all of the content that will be removed when you click the Delete link. The inner frm_edit_container_[id] div holds all of the content that will be replaced with a form when you click the Edit link.