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.

safecracker and checkboxes

December 20, 2011 7:30pm

Subscribe [2]
  • #1 / Dec 20, 2011 7:30pm

    techjob

    22 posts

    No matter what i do safecracker only saves the last checkbox.
    here’s the code used.

    {exp:safecracker channel="sessions" return="contact/thanks" error_handling="inline" logged_out_member_id="6"}
     <input name="equipment" type="checkbox" value="Overhead Projector">Overhead Projector
    
     <input name="equipment" type="checkbox" value="Data Projector">Data Projector (Computer/LCD Panel)
    
     <input name="equipment" type="checkbox" value="Internet Connection">Internet Connection
    
     <input name="equipment" type="checkbox" value="PC Computer">PC Computer
    
     <input name="equipment" type="checkbox" value="Macintosh Computer">Macintosh Computer
    
     <input name="equipment" type="checkbox" value="Flipchart">Flipchart
    
     <input name="equipment" type="checkbox" value="Blackboard">Blackboard
    
     <input name="equipment" type="checkbox" value="VCR/TV">VCR/TV
    
     <input name="equipment" type="checkbox" value="DVD/TV">DVD/TV
    
     <input name="equipment" type="checkbox" value="Microphone">Microphone
    
     <input name="equipment" type="checkbox" value="Computer lab">Computer Lab
    

    all other field work as expected but this checkbox set.
    Pete
    .(JavaScript must be enabled to view this email address)

  • #2 / Dec 21, 2011 8:32am

    Rob Allen

    3114 posts

    If you’re only editing part of an entry you may need to add preserve_checkboxes=“yes” parameter to the exp:safecracker tag

    Also each checkbox input probably needs {checked} adding, eg:

    <input name="equipment" type="checkbox" value="Microphone"{checked}>Microphone
    
    <input name="equipment" type="checkbox" value="Computer lab"{checked}>Computer Lab
    

     

  • #3 / Dec 21, 2011 2:13pm

    Rob Sanchez

    335 posts

    You need to name your input an array:

    <input name="equipment[]"
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases