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

    I’m trying to use

    <input type="checkbox" name="receiveEmails" value="1" checked='checked' />

    OR
    <input type="checkbox" name="receiveEmails" value="1" checked="checked" />


    with eForm but I get
    Fatal error: [] operator not supported for strings in /.../test/assets/snippets/eform/eform.inc.php on line 826 



    Any ideas how to fix this?
      • 26016
      • 561 Posts
      Checkboxes are a little murky with eForm, I think. I seem to recall also having trouble with "checked" The newest edition may have some updates to that. Anyway....

      I do have a quick idea... checkboxes will usually have several values, and thus be subscripted. I believe eForm is expecting the [] in there, so try this on each checkbox "name" part:

      name="receiveEmails[]"
        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 20927
        • 6 Posts
        Was this ever solved? I tried adding the "[]" to the end of the name (ex. name="receiveEmails[]"). It did not make a difference. I have eForm 1.4.4.6 - Electronic Form Snippet.

        Thanks
          • 26016
          • 561 Posts
          I can just show what I’ve done. I can’t speak to issues regarding odd server configs, Windows servers, anything like that. I’ve never gotten a fatal error using checkboxes, just nothing or unpredictable results.

          I also have eForm version 1.4.4.6 in my Evo system. Here’s an example of the form code with the checkboxes in it.
          <input type="checkbox" name="frmColor[]" value="Red" eform="Colours::1" >Red<br />
          <input type="checkbox" name="frmColor[]" value="Yellow">Yellow<br />
          <input type="checkbox" name="frmColor[]" value="Green">Green<br />
          <input type="checkbox" name="frmColor[]" value="Blue">Blue<br />


          ... and in turn, here’s the thing that goes in the form, that should give a comma-separated list of items in the report template:
          Color: [+frmColor+]


          eForm can be tricky - one syntax error, and the form doesn’t work, even if you’ve used it a whole lot, as I have. It’s so much hand-coding. Nancy, it occurs to me that based on your variable name you might be trying to make the email go to one or more recipients. I have not tried that, I have only used the scenario above to get several checked items to be in the report.

          Hope that helps, Dave
            MODx and Wordpress development
            Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
            • 20927
            • 6 Posts
            Thanks for your quick response Dave. My problem is with the checked="checked" or checked=’checked’. They throw the following error:

            Fatal error: [] operator not supported for strings in /var/www/vhosts/myglenbeigh.com/httpdocs/assets/snippets/eform/eform.inc.php on line 826
              • 20927
              • 6 Posts
              Actually, this isn’t quite as straight forward as I’m implying. I have the populate snippet running at the eFormOnBeforeFormParse event. It’s when I try to run the snippet for a selected record that I get the error. But, even when I remove the eFormOnBeforeFormParse event my checkbox doesn’t default to a checked state. eForm just seems to drop the checked=’checked’ from the html. I’ve read some of the other posts on this issue, but it seems that the main response to that issue is to run the latest version and use single quotes. Which I am.
                • 26016
                • 561 Posts
                Ah, I see. Actually, there is stuff in eForm that I could never get to work, even without using that event or anything exotic. It’s been awhile now, but it might have had to do with using "checked", or maybe a checkbox field required, even though the specs seemed to indicate that it would. I can’t remember exactly, it was long ago.

                PHP programmer (or maybe JQuery or Javascript programmer) probably needed, and that isn’t really me. smiley Good luck.
                  MODx and Wordpress development
                  Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
                  • 4310
                  • 2,310 Posts
                  I just tried it on a site running Evo 1.0.4 & eForm 1.4.4.6 successfully with :
                   <label for="receiveEmails"  id="check_label">Newsletter?</label>
                   <input type="checkbox" name="receiveEmails[]" value="1" checked='checked' eform="::0" />
                    • 20927
                    • 6 Posts
                    Thanks for your reply, bunk58. Turns out I was only getting the error when I ran the populate snippet at the eFormOnBeforeFormParse event. I never could get past that. But I seemed to have solved my problem by setting the value of the checkbox to "checked=’checked’" (<input type="checkbox" [+nameofcheckboxfield+] class="checkbox" name="nameofcheckboxfield" value="checked=’checked’" eform="" />). That seemed to get around the whole mess.

                    If I ever need to default a checkbox when using the populate snippet I’ll deal with the error then.

                    Thanks again for everybody’s help.