I've come across this problems enough times now that I'm curious if anyone has sort of a best practice for it that might be helpful.
I have a channel form page that needs to know if the user has already started the application, and there for allow them to edit it, or if if they haven't create a new one.
A simple enough problem it would seem but one I'm constantly tripped up on
Using Stash I've come up with something that "kindof" works but not really
Basically at the top of the page i look for an existing application by that author, something like this
{exp:stash:set name="app_id" parse_tags="yes" type = "snippet"}
{exp:channel:entries channel="applications" author_id="{logged_in_member_id}" limit="1" status="not Closed"}
{entry_id}
{/exp:channel:entries}
{/exp:stash:set}
Which will get the entry id of an application if there is one, and return nothing if there isnt.
then for the application itself do something like this
{if {exp:stash:not_empty name="app_id"}}
{exp:channel:form channel="applications" entry_id="{app_id}" return="step2" }
...
{/exp:channel:form}
{if:else}
{exp:channel:form channel="applications" return="step2" }
...
{/exp:channel:form}
{/if}
Currently there are two issues:
i can get the app_id to render in the page but parse order seems to be an issue as the channel form tag is parsing first and gets an "invalid entry" error, even if its a simple conditional, its always returning false?
{if {exp:stash:not_empty name="app_id"}}{/if}
This method means i have to maintain two copies of the form and just feels messy?
Is there an easier way to do this?
entry_id=""
orentry_id="0"
to your form, does it work as if entry_id param was not present?