FormIt success message output with modifier not showing

I want to output a message after a form has been submitted successfully like this:

[[!+fi.successMessage:notempty=`<p class="success">[[!+fi.successMessage]]</p>`]]

I’ve used the :notempty modifier to hide the p-tag while there is no message to prevent my layout to be broken up by unnecessary margins etc. But after submitting the form nothing is showing up.

If I implement it directly without the modifier, it works fine:

<p class="success">[[!+fi.successMessage]]</p>

I thought that maybe the successMessage technically is never empty because it’s defined in the FormIt hook, but it’s also not showing initially when the page is loaded. Did I use the modifier the wrong way or what am I missing here?

Try this:
[[!+fi.successMessage:notempty=`<p class="success">[[+fi.successMessage]]</p>`]]

Nope, didn’t do it unfortunatley. What’s the difference between [[!+ and [[+?

Uncached and cached tags respectively.

Do you have FormIt call before this placeholder?

No the call comes after the form and I want to display the message above the form. Is that the issue? I thought because it worked without the modifier that it wouldn’t matter…

If I need to have it after the form how can I achieve the same result?

I think it comes down to order of parsing the placeholders/tags. I don’t think it is easy to debug the order.

Did you try putting the Formit call before the form and if it worked?

1 Like

Yes, putting the FormIt call above everything worked! Thanks alot!

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.