entry_id before create

By: lauren scott | Asked: 06/29/2023
ForumsCategory: General questionsentry_id before create
lauren scott asked 1 year ago
Not sure if I am going about this right, but I am basically trying to determine in a form, whether it is a new entry, or editing an existing entry.   My thought was to access the entry id, and if it is null, then it must be a new entry, if it has a value, it is in edit mode on an existing entry. I am wanting to conditionally show a section of fields if it is a new entry, but hide them if it is an edit of an existing entry.    Is there a way to access entry id from a form to determine if the entry already exists, or is there some other way to determine edit from new entry?
2 Answers
Victor Font answered 1 year ago
Formidable's conditional logic works off of other fields on the form. If you know jQuery, this can easily be done with a small jQuery snippet. You're on the right track with the entry ID field. It doesn't exist on a new entry. It's not created until the entry is submitted. As you thought, it does exist on edits and is the value of a hidden field named "id". When you write your jQuery, save it in the before or after fields section on the form's Customize HTML page.
lauren scott replied 1 year ago

awesome, got it. thanks

lauren scott answered 1 year ago
Just as a follow up.  I was thinking, that when you create a new entry the form is usually inserted into a  WP page.   There are no parameters in the URL  However when you edit an entry, the entry id is usualy contained in the URL, ie. somewhat like this: https://website.com/somepage/?entry=[id]     so I tried the [get param=entry] method as a default on a hidden field, and boom, it works.  if there is a value to entry it is an edit, if no value, it is a new entry.   anyway, an alternative that is quicker and easier for anyone who wants to determine whether its an edit or a new entry for conditional logic.   thanks again.  hope this heps.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right