We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40944
    • 78 Posts
    Hi,
    I have searched for a solution, but can't find anything. It's not really a problem with anything in particular, so I think this is the best place to ask this question.

    I have got a subscription form for a contest, beneath the form all the contestants are displayed using my own snippet. I made a (date) TV for the last day to subscribe for to the contest. When that date has past, the form should disappear and only the contestants should be displayed. To achief this I am using a modifier and in the then clause I placed my formit call and form chunk. It seems my formit call is processed without any problem, but my chuck has some ` symbols in there for the error handling for example:
    <li><label for="email">E-mail*:</label>[[+fi.error.email]]<input [[+fi.error.email:isnot=``:then=`class="invalid"`]] type="text" id="email" name="email" value="[[!+fi.email]]" /></li>


    These seem to be interfering with my modifier.

    Complete code:
                [[!today:lte=`[[*subscriptionDate]]`:then=`
                    <div class="grid_12">
                        <h2>Inschrijven</h2>
                        [[*content]]
                    </div>
                    [[!FormIt? &hooks=`...` &validate=`...` ...]]
                    [[$subscriptionForm]]
                `]]


    How do I prevent the ` symbols in my chunk from interfering with my modifier?

    Thanks in advance.

    This question has been answered by BobRay. See the first response.

    [ed. note: might-e last edited this post 13 years, 3 months ago.]
      • 3109 ☆ A M B ☆
      • 894 Posts
      You're missing a closing ]

      Another thing you can try if it still doesn't work is putting your FormIt call in a chunk but check the closing bracket not sure if it was missed while copy and pasting or if it's actually missing.
        Benjamin Marte
        Interactive Media Developer
        Follow Me on Twitter | Visit my site | Learn MODX
        • 40944
        • 78 Posts
        The missing bracket is indeed a copy error. The snippet call is actually not the problem, its the chuck with some ` symbols in there.
          • 37105
          • 194 Posts
          I believe that when you are using single quotes in a chunk call which is also included single quotes you have to replace the inner single quotes into symbol ^

          So in your example it would be:

          [[!today:lte=`[[*subscriptionDate]]`:then=`
          <div class="grid_12">
          <h2>Inschrijven</h2>
          [[*content]]
          </div>
          [[!FormIt? &hooks=^...^ &validate=^...^ ...]]
          [[$subscriptionForm]]
          `]]
            Codeplaza Webdesign: for professional websites at low cost
            • 40944
            • 78 Posts
            Quote from: donquicky at Jul 13, 2013, 05:37 PM
            I believe that when you are using single quotes in a chunk call which is also included single quotes you have to replace the inner single quotes into symbol ^

            So in your example it would be:

            [...]

            Thanks, that should be a solution, but doesn't seem to be working.

            To get things clear:
            I call this piece of code in my template:
            [[!today:lte=`[[*subscriptionDate]]`:then=`
                <div class="grid_12">
                    <h2>Inschrijven</h2>
                    [[*content]]
                </div>
                [[!FormIt? &hooks=`...` &validate=`...` ...]]
                [[$subscriptionForm]]
            `]]


            The FormIt call is actually not causing any problems. When I use the ` symbol it works; the ^ symbol makes it act weird (not working).

            In my subscriptionForm chunk I have got the following code:
            <form action="[[~[[*id]]]]" method="post">
            <div class="grid_6">
                <ul class="nomargin">
                  <li><label for="voornaam">Voornaam*:</label>[[+fi.error.voornaam]]<input [[+fi.error.voornaam:isnot=``:then=`class="invalid"`]] type="text" id="voornaam" name="voornaam" value="[[!+fi.voornaam]]"/></li>
                  <li><label for="tussenvoegsel">Tussenvoegsel:</label>[[+fi.error.tussenvoegsel]]<input [[+fi.error.tussenvoegsel:isnot=``:then=`class="invalid"`]] type="text" id="tussenvoegsel" name="tussenvoegsel" value="[[!+fi.tussenvoegsel]]" /></li>
                  <li><label for="achternaam">Achternaam*:</label>[[+fi.error.achternaam]]<input [[+fi.error.achternaam:isnot=``:then=`class="invalid"`]] type="text" id="achternaam" name="achternaam" value="[[!+fi.achternaam]]" /></li>
                  <li><label for="email">E-mail*:</label>[[+fi.error.email]]<input [[+fi.error.email:isnot=``:then=`class="invalid"`]] type="text" id="email" name="email" value="[[!+fi.email]]" /></li>
                  <li><label for="telefoon">Telefoon:</label>[[+fi.error.telefoon]]<input [[+fi.error.telefoon:isnot=``:then=`class="invalid"`]] type="text" id="telefoon" name="telefoon" value="[[!+fi.telefoon]]" /></li>
                </ul>
            </div>
            <div class="grid_6">
                <ul class="nomargin">
                    <li><label for="paard">Paard/Pony*:</label>[[+fi.error.paard]]<input [[+fi.error.paard:isnot=``:then=`class="invalid"`]] type="text" id="paard" name="paard" value="[[!+fi.paard]]" /></li>
                    <li><label for="vader">Vader Paard/Pony:</label>[[+fi.error.vader]]<input [[+fi.error.vader:isnot=``:then=`class="invalid"`]] type="text" id="vader" name="vader" value="[[!+fi.vader]]" /></li>
                    <li><label for="combi">Combinatienummer:</label>[[+fi.error.combi]]<input [[+fi.error.combi:isnot=``:then=`class="invalid"`]] type="text" id="combi" name="combi" value="[[!+fi.combi]]" /></li>
                    <li><label for="categorie">Categorie*:</label>[[+fi.error.categorie]]
                        <select [[+fi.error.categorie:isnot=``:then=`class="invalid"`]] type="text" id="categorie" name="categorie" value="[[!+fi.categorie]]">
                            <option value="">Selecteer een categorie</option>
                            <option value="0" [[!+fi.categorie:FormItIsSelected=`0`]]>A</option>
                            <option value="1" [[!+fi.categorie:FormItIsSelected=`1`]]>B</option>
                            <option value="2" [[!+fi.categorie:FormItIsSelected=`2`]]>C</option>
                            <option value="3" [[!+fi.categorie:FormItIsSelected=`3`]]>D</option>
                            <option value="4" [[!+fi.categorie:FormItIsSelected=`4`]]>E</option>
                            <option value="5" [[!+fi.categorie:FormItIsSelected=`5`]]>Paard</option>
                        </select>
                    </li>
                    <li><label for="klasse">Klasse*:</label>[[+fi.error.klasse]]<input [[+fi.error.klasse:isnot=``:then=`class="invalid"`]] type="text" id="klasse" name="klasse" value="[[!+fi.klasse]]" /></li>
                </ul>
            </div>
            <div class="grid_12">
                <label for="bijzonderheden">Bijzonderheden:</label>[[+fi.error.bijzonderheden]]<textarea [[+fi.error.bijzonderheden:isnot=``:then=`class="invalid"`]] id="bijzonderheden" name="bijzonderheden">[[!+fi.bijzonderheden]]</textarea>
            </div>
                <input type="hidden" name="wedstrijd" id="wedstrijd" value="[[*pagetitle]]" />
                <input type="hidden" name="pageid" id="pageid" value="[[*id]]" />
                <input type="hidden" name="name" id="name" value="" />
                <div class="grid_12 center"><input type="submit" value="Inschrijven" /></div>
            </form>


            As you can see I have a couple of ` symbols in my chunk here (56 in total). These are used to add a class to a field with an error and to set the select to it's previously chosen value on a failed submit. These are actually causing the problem, and when replaced with the ^ symbol it acts strange (not working either).

            Thanks for your replys so far!

            P.S: about the ^ symbol, can I find documentation on that anywhere?
              • 37105
              • 194 Posts
              Okay, just for testing: could you try to remove the " symbols in your chunk where you define the class invalid? Perhaps these symbols interfere with your snippet.
                Codeplaza Webdesign: for professional websites at low cost
              • discuss.answer
                • 3749
                • 24,544 Posts
                Try putting an :else=`` in your conditional.

                BTW, in the tag with the conditional, everything is going to be parsed (including the FormIt call and the content) whether the condition is true or not, so it will delay page loads even when the condition is not met.

                I would put all the logic in a snippet -- something like this (untested):


                if ((time() <= strtotime($modx->resource->getTVValue('subscriptionDate')))){
                
                    return '<div class="grid_12">
                        <h2>Inschrijven</h2>
                        [[*content]]
                    </div>
                    [[!FormIt? &hooks=`...` &validate=`...` ...]]
                    [[$subscriptionForm]]';
                
                }
                
                return ''; // or something else
                
                


                This will be many times faster than using a conditional output modifier. [ed. note: BobRay last edited this post 13 years, 3 months ago.]
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 40944
                  • 78 Posts
                  Quote from: donquicky at Jul 13, 2013, 06:35 PM
                  Okay, just for testing: could you try to remove the " symbols in your chunk where you define the class invalid? Perhaps these symbols interfere with your snippet.
                  Sadly that didn't work, thanks for your replies anyway!



                  Quote from: BobRay at Jul 13, 2013, 06:41 PM
                  Try putting an :else=`` in your conditional.
                  There is a :else``, but didn't include it in my question to not confuse readers with unnecessary code smiley

                  BTW, in the tag with the conditional, everything is going to be parsed (including the FormIt call and the content) whether the condition is true or not, so it will delay page loads even when the condition is not met.
                  Thanks, I did not know that.

                  I would put all the logic in a snippet -- something like this (untested):


                  <!--?php
                  if ((time() <= strtotime($modx--->resource->getTVValue('subscriptionDate'))){
                  
                      return '<div class="grid_12">
                          <h2>Inschrijven</h2>
                          [[*content]]
                      </div>
                      [[!FormIt? &hooks=`...` &validate=`...` ...]]
                      [[$subscriptionForm]]';
                  
                  }
                  
                  return ''; // or something else
                  

                  Works like a charm! Thanks!

                  PS: Your custom database table tutorial helped me out a lot to, just wanted to thank you for that too!
                    • 3749
                    • 24,544 Posts
                    I'm glad I could help. smiley
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting