New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Passing variable to raven partial is buggy

Jure Judež September 20, 2014 by Jure Judež

Looks like I've struck another bug with Raven.

The Setup

I have Raven form and success in separate partials because I want to reuse raven forms for several forms on the same page. I'm passing id variable to the form so I can get proper success/error messages.

The Files

Contact.html looks like this:

    {{ theme:partial src="raven-info-modal" form-id="whwew" }}
    {{ theme:partial src="raven-form" form-id="whwew" }}

Raven-info-modal partial looks like this:

{{ if {raven:has_errors id="{form-id}"} }}

  <h3>form-id= {{form-id}} </h3>

  <h2>Aww, sorry but you did it wrong:</h2>

  {{ raven:errors id="{form-id}"}}
    {{ missing }}
      <li>{{ field }}: {{ message }}</li>
    {{ /missing }}

    {{ invalid }}
      <li>{{ field }}: {{ message }}</li>
    {{ /invalid }}

  {{ /raven:errors }}
{{ endif}}

{{ if {raven:success id="{form-id}"} }}
   <h3>form-id= {{form-id}} </h3>
    <h1>Good job, son!</h1>

{{ endif }}

And raven-form looks simply like this:

         {{ raven:form formset="contact" id="{form-id}" }}

          <h3>form-id= {{form-id}} << this shouldn't be empty!</h3>

          <label for="name">Your humble name</label>
          <input type="text" name="name" value="" /><br>

          <label for="email">Your electronic mail address</label>
          <input type="email" name="email" value="" /><br>

          <label for="website">Your website</label>
          <input type="text" name="website" value="" /><br>

          <label for="years">Years you too have been stranded</label>
          <input type="text" name="years" value="" /><br>

          <label for="years">Checked?</label>
          <input type="checkbox" name="checked" /><br>

          <input type="submit" value="Submit" />

        {{ /raven:form }}

As you see I'm trying to pass form id to the partials. It seems to work correctly with raven-info-modal partial but not with raven-form. However the success and error message are displayed correctly.

Now comes the tricky part:

I switched to static error/success pages in raven-form.html:

        {{ raven:form 
               return: form-success
               error_return: form-error

Now success and error return don't work anymore, the page just refreshes like in the previously reported bug.

Hope you can squash this one as fast as the first one, Jack.


Answered by Jason Varga!
>>>>>>> Answered <<<<<<<
5 Replies