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.

checkbox value is not saved in the control panel when I use the safecracker module

February 15, 2012 11:35pm

Subscribe [2]
  • #1 / Feb 15, 2012 11:35pm

    dliu

    18 posts

    Hi,

    First I defined channel field name=gbcb_focus_areas, type is checkbox.

    {exp:safecracker channel="gbcb_member_profiles" url_title="{username}” logged_out_member_id=”{member_id}” preserve_checkboxes=“yes”}

    1)
    I can get checkbox value when I use the field tag (below code), but the checkbox layout can not be controlled. Checkbox is displayed horizontal. Can I display the checkbox items in vertical?

    {field:gbcb_focus_areas}<br>


    2)checked checkbox value is not saved in the control panel (below code). Thanks for any suggestion.

    {custom_fields}
    {if checkbox}
    {options}
      <label class=“checkbox”>{option_value}
        <input type=“checkbox” id=”{gbcb_focus_areas}” name=”{gbcb_focus_areas}[]” value=”{option_value}”{checked}><br>
          </label>
      {/options}
    {/if}
    {/custom_fields}

  • #2 / Feb 17, 2012 11:53am

    Shane Eckert

    7174 posts

    Hello dliu,

    I am sorry to hear you are running into this snag with check boxes.

    There is some flexibility with the markup and layout with check boxes.

    If using a field with options, such as Checkboxes or Dropdown, you can display the options in a loop, to give you more control over the markup. You have the four following sub-variables: {option_value}, {option_name}, {selected} and {checked}. (From User Guide)

    Your code looks right for the checkboxes.

    Can you include a screen shot of the channel field “gbcb_focus_areas” in the Control Panel. I would like to see the settings.

    Looking forward to your response.

    Cheers!

  • #3 / Feb 17, 2012 1:46pm

    dliu

    18 posts

    Hi Shane,

    Attached is a screen shot of the channel field “gbcb_focus_areas” in the Control Panel.


    dliu

  • #4 / Feb 20, 2012 11:10am

    dliu

    18 posts

    Hi Shane,

    I found that source code of the page contains “{" and "}” for the id and name.

    It works after I remove them.


    Cheers!

  • #5 / Feb 20, 2012 4:49pm

    Shane Eckert

    7174 posts

    Hello dliu,

    I am glad to hear it. Sounds like those were your own variables and not a part of SafeCracker. I was about to ask you for the contents of the entire template. 😊

    I am glad it is working.

    Thank you for using the ExpressionEngine forums!

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases