On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Hello to all. I have some questions for users with ModX, I have already checked the answers on forum, but no luck till now.

    I have a form which is using recaptchav2. The keys for recaptcha are configured in system settings. If I fill out all the fields without checking the recaptcha checkbox and press submit button, it gives me error on the form, that recaptcha was not checked. If I check the recaptcha and press the submit button, the situation is the same, at both situations I don't get an email. If I remove the hook recaptcha or place it before redirect hook, the emails are sent to me and saved in CMS.

    So I want that my form requires all the fields and checking the recaptcha to make the form working. I'm not sure what is wrong in the code?

    Are there any new ways of changing theme to dark besides this solution: https://forums.modx.com/thread/99538/recaptcha-v2-how-to-change-it-s-theme ?

    [[!FormIt?
    &hooks=`recaptchav2, spam, email, FormItSaveForm, FormItAutoResponder, redirect`
    &recaptchaTheme=`dark`
    &formName=`NameOfForm`
    &emailTpl=`quoteFormEmailTmpl`
    &emailTo=`xxxxxxxx@gmail.com`
    &emailSubject=`Subject`
    &fiarTpl=`quoteFormEmailRspTempl`
    &fiarSubject=`Subject`
    &fiarReplyTo=`xxxxxxxx@gmail.com`
    &validate=`nospam:blank,
    name:required,
    email:email:required,
    place_dep:required,
    place_arr:required,
    date_dep:required`
    &redirectTo=`5`
    ]]
    [[!+fi.validation_error_message:notempty=`<p>[[!+fi.validation_error_message]]</p>`]]
    <form action="[[~[[*id]]]]" method="post">
    <input type="hidden" name="nospam" value="" />
    <div class="form_wrap">
    <div class="field">
    <label>Name</label>
    <input class="solid" type="text" name="name" required="" value="[[!+fi.name]]">


    </div> <span class="error">[[!+fi.error.name]]</span>
    <div class="field">
    <label>e-mail</label>
    <input class="solid" type="email" id="email" class="floatLabel" name="email" value="[[!+fi.email]]">


    </div> <span class="error">[[!+fi.error.email]]</span>
    <div class="field">
    <label>Location 1</label>
    <input class="solid" id="searchTextField" type="text" name="place_dep" placeholder="" value="[[!+fi.place_dep]]">
    </div> <span class="error">[[!+fi.error.place_dep]]</span>
    <div class="field">
    <label>Location 2</label>
    <input class="solid" id="searchTextField2" type="text" name="place_arr" placeholder="" value="[[!+fi.place_arr]]">


    </div> <span class="error">[[!+fi.error.place_arr]]</span>
    <div class="field">
    <label>Arrival</label>
    <input class="solid" id="datepicker" name="date_dep" value="[[!+fi.date_dep]]">


    </div> <span class="error">[[!+fi.error.date_dep]]</span>
    <div class="field back_date">
    <label>Departure</label>
    <input class="solid" id="datepicker2" name="date_arr" value="[[!+fi.date_arr]]">


    </div> <span class="error">[[!+fi.error.date_arr]]</span>
    <div class="checkbox_form"> <span>Add return date</span>
    <div class="checkboxFour">
    <input type="checkbox" value="1" id="checkboxFourInput" />
    <label for="checkboxFourInput"></label>
    </div>
    </div>
    <textarea placeholder="Comment..." name="query" value="[[!+fi.query]]"></textarea>


    <div class="space_btw" style="margin-top:20px;"></div>
    [[!recaptchav2_render]]
    <span class="error">[[!+fi.error.recaptchav2_error]]</span>
    <input type="submit" value="SEND">
    </div>
    </form>

    This question has been answered by multiple community members. See the first response.

    [ed. note: unforgiven666 last edited this post 4 years, 1 month ago.]
    • I haven't looked at the form in depth but I can see some errors straight off the bat such as the end comma on the hook and the missing closing backtick on the validate requirements.
        ■ email: lk@alienbuild.uk | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
      • Hi,
        I'm not familiar with your hook, but i can suggest another which works pretty easy. My co-worker made it for MODX specifically.
        Use it as a preHook.
        https://github.com/bvandorp/reCaptcha_formit_validator
        • Quote from: lkfranklin at Aug 30, 2017, 02:33 PM
          I haven't looked at the form in depth but I can see some errors straight off the bat such as the end comma on the hook and the missing closing backtick on the validate requirements.

          Thanks, I have edited the marks, but even with that, it is the same situation... [ed. note: unforgiven666 last edited this post 4 years, 1 month ago.]
          • Quote from: jorgenh at Aug 30, 2017, 02:47 PM
            Hi,
            I'm not familiar with your hook, but i can suggest another which works pretty easy. My co-worker made it for MODX specifically.
            Use it as a preHook.
            https://github.com/bvandorp/reCaptcha_formit_validator
            Hi, thanks for your reply.

            Now currently my form looks like this:

            [[!FormIt?
            &customValidators=`reCaptcha`
            &hooks=`spam, email, FormItSaveForm, FormItAutoResponder`
            &formName=`FormName`
            &emailTpl=`quoteFormEmailTmpl`
            &emailTo=`xxxxxxxx@gmail.com`
            &emailSubject=`Subject`
            &fiarTpl=`quoteFormEmailRspTempl`
            &fiarSubject=`Subject`
            &fiarReplyTo=`xxxxxxxx@gmail.com`
            &validate=`g-recaptcha-response:reCaptcha=^SECRET^,
            nospam:blank,
            name:required,
            email:email:required,
            place_dep:required,
            place_arr:required,
            date_dep:required`
            ]]

            ....
            ....
            ....

            [[!+fi.error.g-recaptcha-response:notempty=`[[!+fi.error.g-recaptcha-response]]`]]
            <div class="g-recaptcha" data-sitekey="SITEKEY" data-theme="dark"></div>

            The form still submits with or without checking the recaptcha checkbox. But at leat I have changed the theme now! smiley

            Any Idea what is wrong with the code?
            • What's this?

              [[!+fi.error.g-recaptcha-response:notempty=`[[!+fi.error.g-recaptcha-response]]`]]
              <div class="g-recaptcha" data-sitekey="SITEKEY" data-theme="dark"></div>


              It should be:

              [[!recaptchav2_render]]
              [[!+fi.error.recaptchav2_error]]
                ■ email: lk@alienbuild.uk | ■ website: https://alienbuild.uk

                The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
              • You also don't need

                required=""


                If you're using the validation in formit to check. If you do want to use the HTML5 required attribute its just

                required

                  ■ email: lk@alienbuild.uk | ■ website: https://alienbuild.uk

                  The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
                • Quote from: lkfranklin at Aug 31, 2017, 10:06 AM
                  What's this?

                  [[!+fi.error.g-recaptcha-response:notempty=`[[!+fi.error.g-recaptcha-response]]`]]
                  <div class="g-recaptcha" data-sitekey="SITEKEY" data-theme="dark"></div>


                  It should be:

                  [[!recaptchav2_render]]
                  [[!+fi.error.recaptchav2_error]]

                  Hi, I just tried the @jorgenh recommendation. So my code is updated at my first post at the top, I have also deleted the required attributes from the inputs, so FormIt puts his errors at the form. Still the same problem.
                  [ed. note: unforgiven666 last edited this post 4 years, 1 month ago.]
                  • Ah ok.. I haven't seen @jorgenh's method before but looking at this:

                    <div class="g-recaptcha" data-sitekey="SITEKEY"></div>


                    I'd suggest just going back to the original recaptchav2 method though as I use this on most sites and can confirm it works fine.

                      ■ email: lk@alienbuild.uk | ■ website: https://alienbuild.uk

                      The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
                    • Quote from: lkfranklin at Aug 31, 2017, 11:06 AM
                      Ah ok.. I haven't seen @jorgenh's method before but looking at this:

                      <div class="g-recaptcha" data-sitekey="SITEKEY"></div>


                      I'd suggest just going back to the original recaptchav2 method though as I use this on most sites and can confirm it works fine.

                      do you think that this is the problem because I'm testing it on localhost / WAMP server even though i have entered the allowed domains at recaptcha admin site?