Extension, Module

Archived
Forum
(read-only)

Stash

ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6

Back to this add-on's main page
View Other Add-ons From Mark Croxton

     

Stash with Freeform

Support Request

brianrivet
brianrivet

Hi,

I’m working on setting up a contact form in Freeform that will be tied in with Stash. I have a model template that is setting a variable I’m trying to use as a parameter in the contact form. The form generates, and it sends email, but it doesn’t send the email to the address I would expect if the stash variable was setting as expected. It is sending it to the default admin notification address which is what I would expect if the variable isn’t being set when the form code is parsed. Can you tell me if I am doing something wrong here or if I am looking in the wrong place for the problem?

Here’s my code to set the variable in my model template:

{exp:stash:set name="myRepsContactEmails" parse="yes" type="global" trim="yes"}
 
 {exp
:low_search:results channel="zoo_visitor" dynamic="no" status="Representatives-id7" default:child:rep_customers="{custCompany}"}
       
  {exp
:zoo_visitor:details member_entry_id="{entry_id}"}{visitor:email}{/exp:zoo_visitor:details}{if count != total_results}|{/if}                     
    
 
 {
/exp:low_search:results}
 
{
/exp:stash:set} 

And here’s the code for my partial template that displays the form:

<div id="form-wrapper">        
 
 
{exp:freeform:form
 form
:id="login-contact-form"
 
form:role="form"
 
form_name="login_contact"
 
required="first_name|last_name|email|subject|user_message"      
 
return="utilities/contactSuccess"
 
notify_admin="yes"
 
admin_notify="{myRepsContactEmails}"
 
parse="inward"     
 
}
 
 
 
 
<input type="hidden" name="first_name" value="{visitor:global:member_firstname}">
 <
input type="hidden" name="last_name" value="{visitor:global:member_lastname}">
 <
input type="hidden" name="email" value="{logged_in_email}">
 
 
 <
div class="row">
 
  <
div class="form-group col-sm-12">
   <
label for="subject" class="sr-only">Subject</label>
   <
input type="text" name="subject" id="subject"  class="form-control" placeholder="Subject" tabindex="1">
  </
div>
  
 </
div>
 
      
 <
div class="row">
 
  <
div class="form-group col-sm-12">
   <
label for="user_message" class="sr-only">Message</label>
   <
textarea name="user_message" cols="" rows="10"  class="form-control" id="user_message" tabindex="2" placeholder="Your Message"></textarea>
  </
div>
  
 </
div>
 
 
{exp:snaptcha:field}
     
 
<div class="row">
 
  <
div class="form-group col-sm-12">
   <
button type="submit" class="btn btn-blue" value="Submit">Submit</button><span class="processing-message"><img src="/assets/images/ajax-loader.gif"></span>   
  </
div>
  
 </
div>
 
 
 
{/exp:freeform:form}
 
 
<p>{myRepsContactEmails}</p>
 
 
</
div><!--form-wrapper--> 


The paragraph tag at the end is there to verify the variables is set, and it is displaying the expected value. I am just wondering if it is possible that the freeform tag is parsing before the stash variable and so it isn’t getting set as a parameter.

Thanks!

Brian

brianrivet
# 1
brianrivet

Hi Mark,

I wanted to see if you had any insights on what the issue might be here. I’ve tried a few different things like using a stash list instead of just the standard variable, but nothing seems to be working and I’m kind of at a loss as to what the problem might be. I contacted Solspace to see if they had any insight, but they suggested putting the form into an embed and passing the emails as a variable to that, which makes me think they didn’t realize I was using Stash.

Thanks,

Brian

brianrivet
# 2
brianrivet

I did a couple more tests by hardcoding the email address rather than using a stash variable to verify if the problem is with Freeform, but it worked, so I think there is definitely something wrong with how I implemented this in Stash. If you can let me know if you have any input on where I might be going wrong I’d appreciate it.

Thanks!

Mark Croxton
# 3
Developer
Mark Croxton

When you set the ‘myRepsContactEmails’ variable you need to ensure that the tags enclosed are fully parsed. Since you have enclosed 2 nested layers of tags you should set the parse_depth=“2”.

Also, trim=“yes” may not be enough to remove all whitespace, so you may need to close up the tags manually. You can then verify what Stash is capturing by turning on template debug and look for a line Stash: SET myRepsContactEmails ...

brianrivet
# 4
brianrivet

Hi Mark. The parse depth change and removing the extra spaces seems to have fixed the issue. Thanks so much for your help!