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

    I am using formit for my contacts. I have a selector.

    In the html output I am getting an error like:

    Warning: in_array() expects parameter 2 to be array, string given in .../htdocs/cms/core/cache/includes/elements/modsnippet/12.include.cache.php on line 39



    the code from the file 12.include.cache.php:
    $output = ' ';
    if ($input == $options) {
        $output = ' selected="selected"';
    }
    $input = $modx->fromJSON($input);
    if (in_array($options,$input)) {
      $output = ' selected="selected"';
    }
    return $output;
    }
    


    The formular works so far using this code in the chunk:

    <option value="demo1" [[!+fi.thema:FormItIsSelected=`demo1`]] >demo1</option>
       <option value="demo2" [[!+fi.thema:FormItIsSelected=`demo2`]] >demo2</option>
       <option value="demo3" [[!+fi.thema:FormItIsSelected=`demo3`]] >demo3</option>
      <option value="demo4" [[!+fi.thema:FormItIsSelected=`demo4`]] >demo4</option>


    It's working so far - but I don't know why I am getting this errors. Has it maybe something to do with the php version?
    Or Javascript?

    [[!FormIt?
       &hooks=`email,redirect`
       &emailTpl=`email.pro.tpl`
       &emailTo=`[email protected]`
       &redirectTo=`5`
       &emailSubject=`New message`
       &validate=`
          name:required,
          email:required,
          subject:required,
          workemail:blank,
          text:required:stripTags`
     
    ]]


    I also deleted the whole core/cache folder - but the same happened again.

    When I switch to php 5.2 I have the "array" error directly in the frontend.

    Thanks for any infos!

    AD [ed. note: ad2003 last edited this post 11 years ago.]
      • 37031
      • 93 Posts
      Jeff Miranda Reply #2, 11 years ago
      Same thing is happening to me. Not sure what's going on because on my other sites all is good and it's the same code...
        • 37031
        • 93 Posts
        Jeff Miranda Reply #3, 11 years ago
        @ad2003, check out the following URL and see the comment I just made:

        http://tracker.modx.com/issues/9775

        The same thing is happening for radio buttons and there was a fix for it in Git. That same fix will also work for the select box. Essentially in the file snippet.FormItIsSelected.php replace

        if (in_array($options,$input)) {


        with this

        if (!empty($input) && is_array($input) && in_array($options,$input)) {


        Good luck!
          • 42101
          • 125 Posts
          Quote from: jeffmiranda at Apr 24, 2013, 05:14 PM
          @ad2003, check out the following URL and see the comment I just made:

          http://tracker.modx.com/issues/9775

          The same thing is happening for radio buttons and there was a fix for it in Git. That same fix will also work for the select box. Essentially in the file snippet.FormItIsSelected.php replace

          if (in_array($options,$input)) {


          with this

          if (!empty($input) && is_array($input) && in_array($options,$input)) {


          Good luck!

          Nice!

          Thank you Jeff! It worked!

          AD [ed. note: ad2003 last edited this post 11 years ago.]
            • 42101
            • 125 Posts
            Quote from: ad2003 at Apr 24, 2013, 05:45 PM


            Nice!

            Thank you Jeff! It worked!

            AD

            One more thing: I changed it in the
            core\components\formit\elements\snippets\snippet.formitisselected.php


            and also in core/cache - but when I clean the cache or delete it - the arry error warning appears again...
            Why?

            thanks!

            AD
              • 37031
              • 93 Posts
              Jeff Miranda Reply #6, 11 years ago
              Hmm, I thought you mentioned that it worked. Did it come back again even after dumping the cache?
                • 42101
                • 125 Posts
                Yes, it worked. But everytime I am dumping the cache it is set back to the old entry. Even when I changed the original file in core/components...that is very strange - because where does the caching system gets back the old setting?

                Thank you!

                AD

                  • 7327
                  • 195 Posts
                  Hmm, have you tried editing the corresponding snippets within the MODX snippet tree (within the folder named FormIt)? They also appear there.
                    • 42101
                    • 125 Posts
                    Quote from: diatomin at May 04, 2013, 03:01 PM
                    Hmm, have you tried editing the corresponding snippets within the MODX snippet tree (within the folder named FormIt)? They also appear there.


                    uhh...that was a nice hint! smiley I was too stupid to change it there - I just changed it in the directory - I thought that those files were aliase - so that also would change when I change the original ones... Every day, something new to learn.

                    Thank you very much again! - works now!

                    AD
                      • 3749
                      • 24,544 Posts
                      FYI: Generally the snippet .php files are not used by extras. They user the snippets you see in the tree, which come from the database (unless set to static).

                      Also, you should be aware that if you ever upgrade FormIt, your changes will be undone and the problem will come back unless that bug is fixed in the new version.





                      [ed. note: BobRay last edited this post 10 years, 11 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