ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

error on save when using checkbox in safecracker

August 16, 2011 8:20am

Subscribe [3]
  • #1 / Aug 16, 2011 8:20am

    hi,

    i have a problem using EE native checkbox field in Safecracker form. When clicking Submit i get this error: “Disallowed Key Characters.” What’s wrong here?

    Dmitry

    my code:

    {exp:safecracker channel="read" return="read/thanks" url_title="{segment_3}" id="edit_tab_form" safecracker_head="yes" include_jquery="no"}    
    
    {custom_fields}
    {if checkbox}
    {options}
    <label class="checkbox">{option_value}
    <input type="checkbox" id="{col2}" name="{col2}[]" value="{option_value}"{checked}/>
    </label>
    {/options}
    {/if}
    {/custom_fields}
    
    <input type="hidden" name="allow_comments" value="y" {allow_comments} />
    <input type="submit" value="{bbr-mls-save}" class="button_m"/>
    
    {/exp:safecracker}
  • #2 / Aug 16, 2011 6:07pm

    Dan Decker

    7338 posts

    Hi Dmitry,

    Your SafeCracker code all looks good for the time being, can you post the html source that is being output by the template? That’s where the “Disallowed” characters would be displayed.

    Cheers!

  • #3 / Aug 16, 2011 7:18pm

    hi Dan,

    Html source is the same “Disallowed Key Characters.” nothing else. I also tried:

    {exp:safecracker channel="read" entry_id="1158" dynamic="no"}

    - the same result. Can you test this code on your EE 2.2.2 install?

  • #4 / Aug 16, 2011 7:22pm

    what is also strange: ee native checkbox field won’t show up in exp:channel:entries tag. (single or pair, both) Will you have a chance to test it?


    EE2.2.2

  • #5 / Aug 16, 2011 7:29pm

    Dan Decker

    7338 posts

    Dmitry,

    I would love to be able to test this out for you, however my setup wouldn’t mimic your’s closely enough to repeat the errors. The “Disallowed Key Characters” has something to do with either the value of {segment_3} or the value of {col12}

    Can you share with me what those values are?

    Thanks,

  • #6 / Aug 16, 2011 7:55pm

    i changed url_title to entry_id, the same error:

    {exp:safecracker channel="read" entry_id="1158" dynamic="no"}

    The checkbox value “two column”, i tried different values though.

  • #7 / Aug 16, 2011 7:57pm

    just tested on EE 2.2.1 - the same error.

  • #8 / Aug 16, 2011 8:15pm

    Dan Decker

    7338 posts

    Dmitry,

    I think the “space” in “two column” might be the issue. Did you try any values without a space character?

    Best,

  • #9 / Aug 17, 2011 6:41am

    nope,

    the strangest thing i found: using numbers in a field name (for checkboxes) brings that error. After that revelation, another bug appeared: the value of checkbox won’t save on submit. At that moment, i gave up on native ee fields and tried PT checkbox (Brandon Kelly’s a parent) and it worked fine from the first second. The value for that pt checkbox can be 2 words and even in russian (here’s for your test if you fancy: хороший чекбокс)

    too bad you didn’t have a chance to test it on your install.. i want to know is it a bug or just my own issues.

    dmitry

  • #10 / Aug 17, 2011 8:18am

    Dan Decker

    7338 posts

    Hey Dmitry,

    I’m glad you figured out a work around. Now that I have a little more information about the characters you’re using in the native checkboxes, I’ll see if I can replicate. I’ll follow up here with my findings 😊

    Cheers,

  • #11 / Aug 17, 2011 8:38am

    ok thanks!
    it was a challenge to make it work both in exp:channel:entries tag and in safecracker form and i didn’t succeed. it’s funny how simple checkbox can drive someone crazy -)

  • #12 / Aug 18, 2011 5:55pm

    hi Dan,

    did you have a chance to test a checkbox in safecracker to make sure: 1) it will save the value in an entry 2) the value can be two words separated with space?

  • #13 / Aug 21, 2011 3:05am

    FarmBoy

    24 posts

    Dmitry,

    Like Dan mentioned, you might double check the value for your field name and other attributes in:

    <input type="checkbox" id="{col2}" name="{col2}[]" value="{option_value}"{checked}/>

    I was getting the same error of “Disallowed Key Characters” when I submitted my safecracker form with checkbox inputs.  It turned out I was accidentally using a hash “#” sign in my field name, which is filtered out by EE.

    The form submitted fine after I removed the hash, and I’m even using numbers in my field names for the checkboxes.

    For the issue of your checkboxes not saving, try using the following parameter for safecracker:

    preserve_checkboxes="yes"
  • #14 / Aug 21, 2011 12:39pm

    Thanks FarmBoy ! I’ll try that idea on a fresh EE install..

  • #15 / Aug 22, 2011 6:45pm

    Dan Decker

    7338 posts

    Dmitry,

    Please let us know how the fresh install goes. I’m going to move this over into Community Help to keep the discussion open. As always, start a new thread anytime you need assistance.

    Cheers!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases