FormItRetriever

Upon successful submission my form redirects to the success message placeholder on the same page just above the form. I would like to grab the value of the name field and display it in the success message. I’ve done this before using FormItRetriever and it was dead simple but in those cases the success message was on a different page and so far I’ve been unable to get it to work when redirecting to the same page.

Possible?

Thanks

Maybe you can set a custom placeholder in a hook snippet instead.

[[!FormIt? 
   &hooks=`hookSetNamePlaceholder` 
   &validate=`name:required` 
   &successMessage=`Thank you [[!+success.name]], for the message.` 
]] 
[[!+fi.successMessage]]
<form id="myform" action="[[~[[*id]]]]" method="post">    
   <div>
       [[!+fi.error.name]] 
       <label for="name">Name</label> 
       <input type="text" name="name" value="[[!+fi.name]]"> 
   </div> 
   <input type="submit" value="Send"> 
</form>

Snippet hookSetNamePlaceholder

<?php
$name = $hook->getValue('name');
$hook->modx->setPlaceholder('success.name', $name);
return true;

That worked perfectly. Thank you very much.

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”.