We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42184
    • 27 Posts
    I've added a form to my site and it's working fine accept for the fact that the success (successMessage) and error (error_message) messages aren't appearing. The inline error messages for the form fields do appear.

    [[!FormIt?
       &hooks=`email,spam,redirect`
       &emailTpl=`tpl_mailinglist_email`
       &emailTo=`[email protected]`
       &emailSubject=`Mailing List Subscription`
       &validate=`name:required,email:email:required,nospam:blank`
       &successMessage=`Thank you. You have been added to our list.`
    ]]
    
    [[!+fi.successMessage:notempty=`<p class="alert alert-issuccess">[[!+fi.successMessage]]</p>`]]
    
    [[!+fi.error_message:notempty=`<p class="alert alert-iserror">[[!+fi.error_message]]</p>`]]
    
    <form action="[[~[[*id]]]]" method="post">
    	<input type="hidden" name="nospam" value="" />
    
    	<div>
    		<label for="name" class="form-label">Name:</label>
    		<input type="text" name="name" id="name" value="[[!+fi.name]]" class="form-textfield" />
    		<span class="form-error">[[!+fi.error.name]]</span>
    	</div>
    	
    	<div>
    		<label for="email" class="form-label">Email:</label>
    		<input type="text" name="email" id="email" value="[[!+fi.email]]" class="form-textfield" />
    		<span class="form-error">[[!+fi.error.email]]</span>
    	</div>
    	
    	<div class="form-buttons"><input type="submit" value="Subscribe" class="btn" /></div>
    </form>


    Can anyone see what I'm doing wrong?
      • 14677
      • 54 Posts
      This is going to sound silly, but does either of those classes have display: none on them?

      What do you get if you just output:

      [[!+fi.error_message]]


      I've had a problem with notempty before... You could also try...

      [[!+fi.error_message:eq=``:then=`<p class="alert alert-iserror">[[!+fi.error_message]]</p>`]]


      Code above not checked, but should be right. [ed. note: jonrawlins last edited this post 13 years, 10 months ago.]
        • 42184
        • 27 Posts
        No neither of the classes has display:none on them. I tried outputting the error message as you have it above and still nothing appears. Weird!
          • 14677
          • 54 Posts
          As for the success message, why not redirect to another resource?

          [[!FormIt?
             &hooks=`email,spam,redirect`
             &emailTpl=`tpl_mailinglist_email`
             &emailTo=`[email protected]`
             &emailSubject=`Mailing List Subscription`
             &validate=`name:required,email:email:required,nospam:blank`
             &successMessage=`Thank you. You have been added to our list.`
             &redirectTo=`RESOURCEIDHERE`
             &validationErrorMessage=`Testing [[+errors]]`
          ]]
          


          Have you also tried...
          [[!+fi.error.error_message]]

          I've found in some setups the above has strangely worked although it shouldnt. [ed. note: jonrawlins last edited this post 13 years, 10 months ago.]
            • 42184
            • 27 Posts
            Yes, redirecting to a another resource works nicely so I'll use that for the confirmation page.

            I can't get the error message to work at all. The inline error messages on the fields do work though so I'll just use those.

            Looking at other posts on this forum this appears to be a common problem.

            Thanks for your help. smiley
              • 14677
              • 54 Posts
              Your more than welcome, I've known it to work but as with most of the other threads on the forum it seems that 9 out of 10 cases it doesn't. There is no doubt something I may be missing too, it's been a couple of weeks since I last setup a forum but redirecting is sometimes the better option in my opinion. It gives you more options to produce a nicer looking thank you page and add other tagging should you need to smiley

              No problem for the help smiley
                • 40045
                • 534 Posts
                Hm,

                I'm using this "inline" success messages for over an year and it always worked for me...maybe try to set the
                &successMessagePlaceholder=`fi.successMessage`
                explicitly (that's what I have in my FormIt snippet calls...even when it's the same as the default should be)

                what I use then as HTML structure for that global Feedback block is the following

                			<div class="formfeedback">
                				<h3 class="thankyou">[[+fi.successMessage]]</h3>
                				<div class="errors">
                					[[+fi.error.error_message]]
                				</div>
                			</div>
                


                always worked like this =)...
                  • 41825
                  • 16 Posts
                  I know this is an old thread, but I ran into the same issue, that neither [[!+fi.error_message]] nor [[!+fi.error.error_message]] outputs anything. So I looked up the code within the file core/components/formit/model/formit/fivalidator.class.php at line 720 and found out that the placeholder FormIt sets is called "validation_error_message". So [[!+fi.validation_error_message]] did the trick.

                  Edit: ModX Revo 2.2.6 with FormIt 2.1.2
                    • 36446
                    • 184 Posts
                    I had the same problem - fomrit worked but no success messages were shown. - in my case it was caused by insufficient permissions of assets/components/formit
                    maybe this helps someone with the same problems...
                      https://www.beautyislife-shop.de - premium make-up!
                      https://www.topsterne.de - sell it here!
                      ---------------------------------------------------------