We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8071
    • 12 Posts
    Hi, I try to put this snippet in a textarea:

    [[!If? &subject=`[[+fi.bericht]]` &operator=`empty` &then=`Voer een bericht in...` &else=`[[+fi.bericht]]` &debug=`1`]]
    


    Which gives the following output:
    Array
    (
        [subject] => test
    
        [operator] => empty
        [operand] => 
        [then] => Voer een bericht in...
        [else] => test
    
        [debug] => 1
    )
    string(22) "Voer een bericht in..."
    Voer een bericht in...
    

    But the subject ’test’ really is NOT empty?! But the snippet doesn’t seem to get it..
    How can I solve it?

    Thanks
      • 8071
      • 12 Posts
      Nobody knows a solution? Or maybe something else to try??
        • 1778
        • 659 Posts
        Hello

        Did you try
        [[!If? &subject=`[[+fi.bericht]]` &operator=`EQ` &operand=`` &then=`Voer een bericht in...` &else=`[[+fi.bericht]]` `]]
        


        You can also use an output modifier like :
        [[+fi.bericht:is=``:then=`[[+fi.bericht]]`:else=`Voer een bericht in...` ]]
        


        Hope this helps, feel free to ask if you still in trouble
        Cheers
          • 8071
          • 12 Posts
          Hi,

          First of all thanks for your help.
          But unfortunately it still doesn’t work.
          When I try the first code (operator=EQ operand=``), I have the same problem. It only shows ’Voer een bericht in..’. Even if [[+fi.bericht]] is not empty.

          When I try the second one, (+fi.bericht:is=``:then=`[[+fi.bericht]]`:else=`Voer een bericht in...`) it only shows [[+fi.bericht]], even if I posted the form with a value in the textarea.

          Really strange... huh sad
            • 1778
            • 659 Posts
            May be a problem with your form ...
            I can have a look if you want (with absolutly no guarantee to find something helpful) could you post your code or send it to me via PM?
            Cheers
              • 33976 ☆ A M B ☆
              • 571 Posts
              Hi,

              i had the same problem while testing with operator "empty". Maybe could you file a bug @ http://bugs.modx.com open an issue @ http://github.com/splittingred/If/issues smiley
              Anyway you could also try :
              [[!+fi.bericht:is=``:then=`NULL`:else=`NOT NULL`]]


              Hope that helps

              Edit : Anso was faster than me (and i didn’t read efficiently, sorry)
                • 8071
                • 12 Posts
                Okay, here is the full code of the form (FormIt snippet) with the If-snippet/Output-modifier-tags (without some extra HTML):
                <p>[[+fi.error.error_message]]</p>
                
                <form action="[[~[[*pageid]]]]" method="post">
                <input name="nospam:blank" type="hidden" />
                
                <label for="naam">Naam</label>
                <input id="naam" name="naam" value="[[+fi.naam]]" /><br />[[+fi.error.naam]]
                
                <label for="email">E-mail adres</label>
                <input id="email" name="email" value="[[+fi.email]]" /><br />[[+fi.error.email]]
                
                <label for="onderwerp">Onderwerp</label>
                <input id="onderwerp" name="onderwerp" value="[[+fi.onderwerp]]" /><br />[[+fi.error.onderwerp]]
                
                <textarea onclick="this.focus(); this.select();" name="bericht">
                [[+fi.bericht:is=``:then=`[[+fi.bericht]]`:else=`Voer een bericht in...`]]
                </textarea><br />
                [[+fi.error.bericht]]
                
                [[!+formit.recaptcha_html]] <br /><br />[[+fi.error.recaptcha]] 
                
                <input class="button" style="float: right;" name="submit" type="submit" value="Verzenden" />
                </form>
                
                
                [[!FormIt? &hooks=`recaptcha,spam,email,redirect` &errTpl=`<div style="color: red; font-weight: normal;">[[+error]]</div>` &recaptchaTheme=`white` &emailTo=`[email protected]` &redirectTo=`19` &validate=`naam:required,email:required:email,bericht:required`]]
                <div style="clear:both;"> </div>
                
                


                I hope you can find a solution for the problem with this full code tongue
                  • 1778
                  • 659 Posts
                  Hello

                  Try this
                  <textarea onclick="this.focus(); this.select();" name="bericht" [[+fi.bericht:is=``:then=`[[+fi.bericht]]`:else=`Voer een bericht in...`]]></textarea><br />
                  [[+fi.error.bericht]
                  


                  As you can see I put the modifier inside the <textarea> tag, ... It should work I guess, let me know, I can’t test it right now ^_^

                  Cheers
                    • 8071
                    • 12 Posts
                    Hi,

                    Thanks for your help, but unfortunately it still doesn’t work sad
                    Now the textarea is always empty, strange.. That would mean that it should be after <textarea>, but it is more about the modifier I think (the is-then-else part)... But how to solve it..
                      • 1778
                      • 659 Posts
                      Sorry to hear it does not work... Indeed I never tried this with a textarea... It works fine with "<input type="text">"...

                      So the only solution I see is to write a snippet that displays the text area filled in with "Voer een bericht in..." in case it’s value is empty... Something like
                      $bericht = $_POST['bericht'];
                      
                      if($bericht==''){
                        $output = '<textarea onclick="this.focus(); this.select();" name="bericht">Voer een bericht in...</textarea>';
                      }
                      else{
                        $output = '<textarea onclick="this.focus(); this.select();" name="bericht">[[+fi.bericht]]</textarea>';
                      }
                      return $output;
                      


                      Hope this can help you, or put you on a way you can explore further...
                      Cheers