1

I'm trying to add/edit a channel entry using Safecracker but my checkboxes in the form aren't showing up in the CP when I check the entry.

Any ideas? The Field Pack extension is enabled, as is the field type. Here's the template code within Safecracker:

        {options:therapy-coursemethods}
        <label for="coursemethods-{option_value}"><input type="checkbox" name="therapy-coursemethods[]" value="{option_value}" id="coursemethods-{option_value}"> {option_name}</label><br>
        {/options:therapy-coursemethods}

Here's the html:

        <label for="coursemethods-method1"><input type="checkbox" name="therapy-coursemethods[]" value="method1" id="coursemethods-method1"> Method 1</label><br>            
        <label for="coursemethods-method2"><input type="checkbox" name="therapy-coursemethods[]" value="method2" id="coursemethods-method2"> Method 2</label><br>            
        <label for="coursemethods-method3"><input type="checkbox" name="therapy-coursemethods[]" value="method3" id="coursemethods-method3"> Method 3</label>
3
  • What versions of EE and the Field Pack are you using?
    – Lisa
    May 1, 2013 at 14:22
  • Hi Lisa. The fieldpack is 1.0.3 and EE is 2.5.5. May 3, 2013 at 16:21
  • Did you try the field syntax for that custom field? ie: {field:field_name} in safecracker? That should load all the needed items from that field for you.
    – Lisa
    May 31, 2013 at 16:10

2 Answers 2

1

Ensure that you include the preserve_checkboxes="yes" parameter in your Safecracker form. More info can be found here in the docs.

HTML checkboxes have an interesting quirk in that if they are not checked they are not sent in the form POST submission. Safecracker therefore can't distinguish between an unchecked checkbox and an omission in the form submission.

3
  • I got excited there for a minute, but, no, it makes no difference. Even creating a new entry makes no difference. Thanks, though. Am I missing anything obvious in my code? May 1, 2013 at 12:01
  • Try name="{therapy-coursemethods}[]". Also, it may be worth checking that you have P&T Field Pack enabled in the Addons section.
    – Ian Young
    May 1, 2013 at 13:56
  • No, that just displays name="[]" May 3, 2013 at 16:20
1

I'd been having issues with PT Checkbox in a Safecracker form as well. For me, this worked:

{options:field_name}
  {label:field_name}
    <input type="checkbox" id="field_name[]" name="field_name[]" value="{option_value}"{checked}>{option_value}

{/options:field_name}

Where field_name represents the actual field name. This is EE 2.6.1, Safecracker 2.1 and Field Pack 2.0.2. As noted above, you have to include preserve_checkboxes="yes"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.