I'm using Stash in a few ways. First, as a layout template (.layout-account.html). Second, to get variables for testing. But I'm struggling with the final part.
I have two channels - Users (via Zoo Visitor) and Firms. I want the user to be able to edit their own firm via a safecracker form. There exists a Playa field within the Zoo Visitor channel called "Firm". It let's my client choose the correct firm that the user belongs to from the Firms channel.
I have a Low Variable called {lv_stash_get_firm_id}. This calls a {channel:entries} to get the value of the Playa field for their firm.
{exp:channel:entries channel="zoo_visitor" limit="1" author_id="{logged_in_member_id}" status="HCAA_Members-id5|Open" parse="inward"}
{exp:stash:set name="firm_url"}
{embed="includes/.get_firm" entry_ids="{member_firm_name:child_ids}"}
{/exp:stash:set}
{/exp:channel:entries}
The template .get_firm looks like this:
{exp:channel:entries channel="firms" fixed_order="{embed:entry_ids}" fixed_order="0|{embed:entry_ids}" dynamic="no" disable="member_data|pagination|categories" status="not closed" parse="inward"}
{entry_id}
{/exp:channel:entries}
My template for manage-firm-info looks like this:
{embed="layouts/.layout-account" site_top="public_top" security="yes"}
{lv_stash_get_firm_url}
{exp:stash:main_content}
{if last_segment == "success"}
<p class="profile-update-success">Your information has been updated.</p>
{/if}
{exp:safecracker channel="firms" entry_id="42" return="/profile/{segment_2}/{segment_3}/success" parse="inward"}
... Stuff ...
{/exp:safecracker}
{/exp:stash:main_content}
The .layout-account controls all of the header and footer stuff, etc., and also calls {exp:stash:main_content}
Everything works fine if I use:
{exp:safecracker channel="firms" entry_id="42" return="/profile/{segment_2}/{segment_3}/success"}
or (assuming the entry_id is in the URL)
{exp:safecracker channel="firms" entry_id="{segment_3}" return="/profile/{segment_2}/{segment_3}/success"}
But obviously that won't work as the entry_id won't be the same for each user. Also, I'd rather not show the entry_id in the URL as someone could then modify it and change someone else's firm.
So I thought I would try to use Stash to set the firm_id and them pass it into the Safecracker form like this: {exp:safecracker channel="firms" entry_id="{stash:firm_url}" return="/profile/{segment_2}/{segment_3}/success"}
However, that doesn't work.
If I add {exp:stash:firm_url} prior to the Safecracker form, it spits out the correct entry_id. So it's getting that far. But it's not getting to the Safecracker form as it gives me an error that I need a valid entry to edit.
I'm guessing this is a parsing or syntax issue but I just can't quite get there.
Any help or suggestions are greatly appreciated!!