We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8489
    • 90 Posts
    I can’t get the value of the radio buttons in the email, did I overlooked something?

    Template:
    Betaling geschiedt per: [[+betaling]]

    Snippet:

    [[!FormIt?
    &hooks=`spam,email,redirect`
    &emailTpl=`sentEmailTpl`
    &emailSubject=`Bestelling`
    &emailTo=`[email protected]`
    &redirectTo=`2183`
    &validate=`email:email:required,
    betaling:required`
    ]]

    Radios
    <input type="radio" value="bank" name="betaling[]" [[!+fi.betaling:FormItIsChecked=`bank`]] id="bank" />
    <input type="radio" value="paypal" name="betaling[]" [[!+fi.betaling:FormItIsChecked=`paypal`]] id="paypal" />
    • Hey. Saw your tweet.

      Your radio should not have an array name but a single value and for validation to work you need to have a hidden input to set the value initially for formit to validate against.

      <?php  //for syntax highlighting
      
      <input type="hidden" name="betaling" value="[[!+fi.betaling]]" />
      <input type="radio" value="bank" name="betaling" [[!+fi.betaling:FormItIsChecked=`bank`]] id="bank" />
      <input type="radio" value="paypal" name="betaling" [[!+fi.betaling:FormItIsChecked=`paypal`]] id="paypal" /> 
      
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. BlogTwitterLinkedInGitHub
        • 8489
        • 90 Posts
        Thanks Smashingred for your reply,
        I need the array name for Jquery validate:


        var validator = $("#validate").validate({
        rules: {
        email: { email:true, required: true },
        "betaling[]": { required: true }
        },
        messages: {
        email: { required:"*Email adres vereist.", email:"*Vul een geldig email adres in." },
        "betaling[]": "Maak een keuze voor betaling"
        },
        errorPlacement: function(error, element) {
        error.appendTo("#form-error");
        }
        });
          • 8489
          • 90 Posts
          I have it working now and the chosen radio is printed out in the email.

          The only thing is that the snippet [[+betaling.1:notempty=`[[+betaling.1]]`]] from the not chosen radio is also printed out in the email. How could I remove this from the email?

          Template:
          [[+betaling.0:notempty=`[[+betaling.0]]`]]
          [[+betaling.1:notempty=`[[+betaling.1]]`]]

          Snippet:
          [[!FormIt?
          &hooks=`spam,email,redirect`
          &emailTpl=`sentEmailTpl`
          &emailSubject=`Bestelling`
          &emailTo=`[email protected]`
          &redirectTo=`2183`
          &validate=`email:email:required,
          betaling:required`
          ]]

          Radios:
          <input type="radio" value="bank" name="betaling[]" [[!+fi.betaling:FormItIsChecked=`bank`]] id="bank" />
          <input type="radio" value="paypal" name="betaling[]" [[!+fi.betaling:FormItIsChecked=`paypal`]] id="paypal" />

          • If you just remove the array, you can just do it like you posted in the first post...

            You can just modify the jQuery validator right?
            "betaling[]": { required: true }

            "betaling": { required: true }
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
            • I am wondering why the double glove? Do you not want the page reload before validation? I find formit validation and errors pretty simple and only require doing one validation set. Only case where I wouldn’t want to do this is if I didn’t want page reload. In any case, glad it’s working.
                Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. BlogTwitterLinkedInGitHub
                • 8489
                • 90 Posts
                Thanks Mark H,

                Everything is working fine except that in the email template the notempty doesnt seems to work.
                • If you don’t use the array, there’s no need to use notempty.

                  Just use [[+betaling]] - there’s only one value being passed anyway.

                  With checkboxes you need the arrays, but with radiobuttons you don’t as it’s just being passed as is - one selected value.

                  I do seem to recall having issues with notempty in some cases as well.. can’t remember specifics though.
                    Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                    Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                    • 8489
                    • 90 Posts
                    Quote from: smashingred at May 22, 2011, 01:38 PM

                    I am wondering why the double glove? Do you not want the page reload before validation? I find formit validation and errors pretty simple and only require doing one validation set. Only case where I wouldn’t want to do this is if I didn’t want page reload. In any case, glad it’s working.

                    I prefer not to reload the page, do you think it is easy to make it Multi Lingual with the formit validation and errors, that was one of the reasons I used Jquery validation.
                      • 8489
                      • 90 Posts
                      Quote from: Mark at May 22, 2011, 01:43 PM

                      If you don’t use the array, there’s no need to use notempty.
                      Just use [[+betaling]] - there’s only one value being passed anyway.
                      With checkboxes you need the arrays, but with radiobuttons you don’t as it’s just being passed as is - one selected value.
                      I do seem to recall having issues with notempty in some cases as well.. can’t remember specifics though.

                      Then it’s maybe better to use the formit validation and errors instead with the notempty not working, do you know if multi lingual errors is easy to set up.