We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!

Answered Formit and Migx

    • 43864
    • 151 Posts
    I have a Migx with a list of items (changeable products). I use that list in a Formit and next to each item the user can input a value. (for example: product-x --> value = 5, product-y --> value = 26). I want that list to be mailed, so al the products in that list with a value greater dan 0. See it as a sort of order-mail.

    First, in my Formit I use:
    [[!getImageList? &tvname=`products` &tpl=`productvalue`]]


    the tpl productvalue looks like this:
    <li>[[+product]]: <input name="[[+product]]" type="text" id="[[+product]]" value="[[+fi.[[+product]]]]" [[+fi.error.[[+product]]:isnot=``:then=`class="fielderror"`:else=`class="field"`]]></li>


    I do get the list on the form to fill in, but how to I store the values so I can use them to email? I want to receive an email with the list and the values next to them. Also the error-check is not working (isNumber:required).

    Can somebody help me please?

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

      • 4172
      • 5,888 Posts
      what is your current formit-call?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 43864
        • 151 Posts
        Quote from: Bruno17 at Apr 15, 2013, 03:08 PM
        what is your current formit-call?

        [[!FormIt? &validate=`workemail:blank,name:required,email:email:required,[[+product]]:isNumber`
        &hooks=`email,redirect`
        &emailSubject=`order form`
        &emailTpl=`OrderTplMain`
        &emailTo=`[[++email]]`
        &submitVar=`order_main`
        &redirectTo=`179`
        &spamEmailFields=`email,naam`
        &validationErrorMessage=`<p>Please correct the following fields:</p><br />`


        the OrderTplMain is working for the regular data like name, address, ... but how to I get the list with products (taken from a Migx on the form) in it? I Have to put it in an array I think, but don't know how to do that in this case. I haven't much knowledge of php.
          • 4172
          • 5,888 Posts
          this should work:

          In your email-chunk place a getImageList-snippet - call:

          <ul>[[getImageList? &tvname=`products` &tpl=`mail_product`]]</ul>


          and in mail_product have:

          [[+[[+product]]:notempty=`
          <li>[[+product]]:[[+[[+product]]]]</li>
          `]]


          I tested this and it did it.

          Should also be possible to build the validator by getImageList
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 43864
            • 151 Posts
            @Bruno17: this is not working. I want to get the list of products with next to it the number they order. For example:


            • Product-x: 45
            • Product-y: 78
            • Product-z: 11

            In the form the visiter is seeing the product-list with next to each product a field to fill in a number (how much they want to order).

            I suppose my code in the first tpl (the output in the form) isn't also correct:
            <li>[[+product]]: <input name="[[+product]]" type="text" id="[[+product]]" value="[[+fi.[[+product]]]]" [[+fi.error.[[+product]]:isnot=``:then=`class="fielderror"`:else=`class="field"`]]></li>


            Then I need to take te results and put them in a mail that is forwarded. So in the mail the list is printed, but the products with value 0 must not be printed.

            Second I want an error-check on the form to make sure they fill in a number and nothing else.

            For normal data the form is working perfect, so I do get the mail, but not with the product-list with correct values next to it.

            Hope that's more clear.
              • 4172
              • 5,888 Posts
              this is exactly what my solution above does.
              As said above, I tested it and it is working.
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 43864
                • 151 Posts
                Let's say the product is called 'red flower' and the visiter orders 5 pieces. (red flower: 5)

                If I do exactly like you say, then in the mail I receive I get the code looking like this (it outputs the code literal):

                [[+red flower:notempty=` 
                •	red flower:[[+red flower]]
                `]]
                


                Do you also have a Migx where the webmaster can fill in the products that are listed in the form? That list is outputted in the form with next to it an input field for the amount to be filled in. I want that list in a mail to me.

                Important is that the input field for the amount is not in the Migx, so for the result in de email I have to get the productlist of the Migx and the fields of the form put together.

                @Bruno17: your solution outputs the code above in the mail, so something must be wrong.

                I know it's difficult to explain.
                • discuss.answer
                  • 4172
                  • 5,888 Posts
                  I have it exactly configured like you did.

                  first thing: did you call getImageList in your mail-chunk with cached tags as I did ?
                  [[getImageList

                  sounds like you have it called with uncached tags:
                  [[!getImageList


                  second thing: the product-names shouldn't have any special chars, like spaces in it, when they are going to be names for your inputs.

                  not good:
                  <input name="red flower"


                  better would be to use the MIGX_id for example:

                  <li>[[+product]]: <input name="amount[[+MIGX_id]]" type="text" id="amount[[+MIGX_id]]" value="[[!+fi.amount[[+MIGX_id]]]]" [[+fi.error.amount[[+MIGX_id]]:isnot=``:then=`class="fielderror"`:else=`class="field"`]]></li>


                  and in your getImageList - chunk for the mail:

                  [[+amount[[+MIGX_id]]:notempty=`
                  <li>[[+product]]:[[+amount[[+MIGX_id]]]]</li>
                  `]]


                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                  • discuss.answer
                    • 4172
                    • 5,888 Posts
                    And here is the solution for your validator:

                    &validate=`[[!getImageList? &tvname=`products` &tpl=`@CODE:amount[[+MIGX_id]]:isNumber` &outputSeparator=`,`]]`
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 43864
                      • 151 Posts
                      @Bruno17: Thx! Works great now! The problem was indeed the caching on the getimagelist.

                      Thx for your patience and support.