We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I suspect this is more a bug in toPlaceholders than in FormItRetriever. I would like to see some results from testing toPlaceholders with different types of objects and arrays.
      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
      • 8921
      • 55 Posts
      Thanks everyone for your replies. Unfortunately this has seemed to have gone into the realm of "way beyond my abilities and understanding".

      I guess my next question then is could a custom hook and snippet be written to deal with making sure the checkboxes stay checked? I'm presuming "yes", but not sure how to proceed on this?
        • 32316
        • 387 Posts
        I guess my next question then is could a custom hook and snippet be written to deal with making sure the checkboxes stay checked? I'm presuming "yes", but not sure how to proceed on this?
        Of course the answer is yes.
        If one knows php it could probably be done faster than figuring out why FormIt is not working!

        How to proceed depends on what you are trying to do - in more detail than "I'm trying to keep a check box checked".
        Detail would be: when validation fails, or when ...
        Detail would be: the checkboxes are an array of values... (I say this because if you give each check box its own name FormIt can keep them checked, it only seems to have problems with arrays of checkboxes - so calling them test1, test2, etc works, calling them all test[] fails) If you can deal with them having separate names you could use FormIt.

          • 32316
          • 387 Posts
          One way to do it would be to write a snippet that:

          grabbed the POST data
          sanitized and parsed the data
          created MODX placeholders (contents of the placeholder would be ' checked="checked" ')

          then you could just use the placeholders in your form.
            • 8921
            • 55 Posts
            Thank you everyone. I ended up just using unique names for each one rather than an array - this works as per previous posts in this thread.

            My last question now is how do I make these checkboxes checked by default?
              • 46407
              • 5 Posts
              I am using Formit 2.2.0 with Formsave 1.1.0. I tried those same tag placeholders in Static html file that my modx chunk references that holds the formit calls "

              [[!+fi.fieldname:FormItIsChecked=`optionvalue`]

              and then

              [tt][[!+fi.fieldname:FormItIsChecked=`optionvalue`]][/tt]

              But it does not save. Also in the text editor package I use Ace, these 2 lines give error on the side:
              "Unexpected Character in Unquoted Attribute"

              Any reason why this is happening?