We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51354
    • 11 Posts
    I've this situation:

    <input type="checkbox" name="group[[[+name]]-[[+id]]]" value="1">


    This will fail because of the triple [.

    How can i get around it? I cant use &#91; because this will result in:

    <input type="checkbox" name="group&#91;example-1]" value="1">
      • 3749
      • 24,544 Posts
      It's very unusual to have a value in the brackets of a checkbox (I've never seen it done). Are you sure you don't mean one of these?


      <input type="checkbox" name="group[[+name]]-[[+id]][]" value="1">
      
      <input type="checkbox" name="group[[+name]]-[[+id]]" value="1">
        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
        • 2611
        • 394 Posts
        Try:
        <input type="checkbox" name="group[ [[+name]]-[[+id]] ]" value="1">


        Or
        <input type="checkbox" name="group['[[+name]]-[[+id]]']" value="1">
          Follow me on twitter: @b03tz
          Follow SCHERP Ontwikkeling on twitter: @scherpontwikkel
          CodeMaster
          • 51354
          • 11 Posts
          Quote from: BobRay at Nov 25, 2015, 03:12 PM
          It's very unusual to have a value in the brackets of a checkbox (I've never seen it done). Are you sure you don't mean one of these?


          <input type="checkbox" name="group[[+name]]-[[+id]][]" value="1">
          
          <input type="checkbox" name="group[[+name]]-[[+id]]" value="1">

          No... And it's not that strange... I use it often. See http://stackoverflow.com/a/6152470/3269816
            • 3749
            • 24,544 Posts
            Fair enough (I was thinking of radio options, where that would make less sense).

            Can you be more specific about what you mean by "This will fail" ?

            The placeholders should be replaced by the time the page is rendered, so the browser would never see the triple brackets. Are you saying that MODX is failing to parse the tag correctly? b03tz's suggestion might help with that.
              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
              • 51354
              • 11 Posts
              Quote from: b03tz at Nov 26, 2015, 02:45 AM
              Try:
              <input type="checkbox" name="group[ [[+name]]-[[+id]] ]" value="1">


              Or
              <input type="checkbox" name="group['[[+name]]-[[+id]]']" value="1">

              The first one results in:
              ["group"]=>
                array(1) {
                  [" 2 "]=>
                  string(1) "1"
                }

              (Including spaces in the key)

              The second one in:
              ["group"]=>
                array(1) {
                  ["'2'"]=>
                  string(1) "1"
                }


              Both not what i want...
                • 51354
                • 11 Posts
                For now i used a snippet as workaround.

                Snippet name: createSafeName

                Snippet code:
                return "group[" . $input1 . "-" . $input2 . "]";


                Snippet call:
                <input type="checkbox" name="[[!createSafeName? &input1=`[[+name]]` &input2=`[[+id]]`]]" value="1" >


                Of course this works, but i don't like it!
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  It doesn't surprise me that this wouldn't work, MODX will try to figure out what kind of MODX tag [[[ is and of course fail, since there is no such tag. I think that two brackets without a following tag identifier is taken to mean "snippet", so what you have there is a snippet with a very strange name which of course doesn't exist so nothing is output. The inner full placeholder will be processed, so you'll end up with something like "group-1]"
                    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
                    • 51354
                    • 11 Posts
                    Quote from: sottwell at Nov 30, 2015, 08:00 AM
                    It doesn't surprise me that this wouldn't work, MODX will try to figure out what kind of MODX tag [[[ is and of course fail, since there is no such tag. I think that two brackets without a following tag identifier is taken to mean "snippet", so what you have there is a snippet with a very strange name which of course doesn't exist so nothing is output. The inner full placeholder will be processed, so you'll end up with something like "group-1]"

                    Yep, i got that. Do you have any idea how to solve this? No way to really escape the tags?
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Sorry, no idea. Unless you install pdoTools and enable and use the Fenom parser syntax instead of MODX tags.
                        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