2

I have a channel form with several checkbox fields. They go in fine but when I try to edit the form content the edits do not save. The rest of the fields save when edited so I am looking for how to modify the checkbox fields and have them save properly.

Here is the code for the entire form.

{exp:channel:form channel="facilities" url_title="{segment_3}" author_id="CURRENT_USER"  return="supply-chain/facility-preview/ENTRY_ID" }

    <input type="hidden" id="facilityCounter" value="1" />
     <div id="facilities">
       <fieldset class="facility-info">

        <dl>
        <dt><label>Facility Name*</label></dt>
        <dd class="validate"><input type="text" name="title" class="required" value="{title}"></dd>

        <dt><label>Street address*</label></dt>
        <dd class="validate"><input type="text" name="facility_street_address" class="required" value="{facility_street_address}"></dd>

        <table class="city-state-zip">
            <thead>
                <tr>
                    <th scope="col">City*</th>
                    <th scope="col">State*</th>
                    <th scope="col">Zip*</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="validate"><input type="text" name="facility_city" class="required"  value="{facility_city}"></td>
                    <td><!--<input type="text" name="facility[1][facility_state]" value="">-->
                                <select name="facility_state">
                                <option selected value="{facility_state}">{facility_state}</option>
                                <option value="AL">Alabama</option>
                                <option value="AR">Arkansas</option>
                            <option value="FL">Florida</option>
                            <option value="GA">Georgia</option>
                            <option value="KY">Kentucky</option>
                            <option value="LA">Louisiana</option>
                            <option value="MI">Mississippi</option>
                            <option value="NC">North Carolina</option>
                            <option value="SC">South Carolina</option>
                            <option value="VA">Virginia</option>
                         </select>

                    </td>
                    <td class="validate"><input type="text" name="facility_zip" class="zip required" value="{facility_zip}"></td>
                </tr>
            </tbody>
        </table>
        <dt><label>Facility description*</label></dt>
        <dd class="validate"><textarea name="facility_description" class="required">
        {exp:eehive_hacksaw}
                {facility_description}
        {/exp:eehive_hacksaw}
        </textarea></dd>
            </dl>

        <p>This facility supplies components or services for:</p>

            <table class="survey">

                <thead>
                    <tr>
                        <th scope="col">&nbsp;</th>
                        <th scope="col">Currently<br />Supply</th>
                        <th scope="col">Don't Currently<br /> But Could Supply</th>

                    </tr>
                </thead>
                <tbody>
                    <tr class="nacelle">
                        <td>Nacelle</td>
                        <td><img src="/photos/arrow_down.png" alt=""><input type="checkbox" name="nacelle[data][]" value="{nacelle}" {if nacelle == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/arrow_down.png" alt=""><input type="checkbox" name="nacelle[data][]" value="{nacelle}" {if nacelle == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="nacelle-group">
                        <td class="title">Drivetrain / Gearbox</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="drivetrain_gearbox[data][]" value="{drivetrain_gearbox}" {if drivetrain_gearbox == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="drivetrain_gearbox[data][]" value="{drivetrain_gearbox}" {if drivetrain_gearbox == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="nacelle-group">
                        <td class="title">Generator / Electrical</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="generator_electrical[data][]" value="{generator_electrical}" {if generator_electrical == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="generator_electrical[data][]" value="{generator_electrical}" {if generator_electrical == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="nacelle-group">
                        <td class="title">Control System</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="control_system[data][]" value="{control_system}" {if control_system == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="control_system[data][]" value="{control_system}" {if control_system == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="nacelle-group">
                        <td class="title">Yaw / Pitch</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="yaw_pitch[data][]" value="{yaw_pitch}" {if yaw_pitch == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="yaw_pitch[data][]" value="{yaw_pitch}" {if yaw_pitch == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="nacelle-group">
                        <td class="title">Housing</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="housing[data][]" value="{housing}" {if housing == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="housing[data][]" value="{housing}" {if housing == "could-supply"}checked="yes"{/if}></td>
                    </tr>


                    <tr class="professional">
                        <td>Professional Services</td>
                        <td><img src="/photos/arrow_down.png" alt=""><input type="checkbox" name="professional_services[data][]" value="{professional_services}" {if professional_services == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/arrow_down.png" alt=""><input type="checkbox" name="professional_services[data][]" value="{professional_services}" {if professional_services == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="professional-group">
                        <td class="title">Engineering</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="engineering[data][]" value="{engineering}" {if engineering == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="engineering[data][]" value="{engineering}" {if engineering == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="professional-group">
                        <td class="title">Environmental Services</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="environmental_services[data][]" value="{environmental_services}" {if environmental_services == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="environmental_services[data][]" value="{environmental_services}" {if environmental_services == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="professional-group">
                        <td class="title">Law / Finance</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="law_finance[data][]" value="{law_finance}" {if law_finance == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="law_finance[data][]" value="{law_finance}" {if law_finance == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="professional-group">
                        <td class="title">Other Consulting</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="other_consulting[data][]" value="{other_consulting}" {if other_consulting == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="other_consulting[data][]" value="{other_consulting}" {if other_consulting == "could-supply"}checked="yes"{/if}></td>
                    </tr>


                    <tr class="services">
                        <td>Field Services</td>
                        <td><img src="/photos/arrow_down.png" alt=""><input type="checkbox" name="field_services[data][]" value="{field_services}" {if field_services == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/arrow_down.png" alt=""><input type="checkbox" name="field_services[data][]" value="{field_services}" {if field_services == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="services-group">
                        <td class="title">Construction</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="construction[data][]" value="{construction}" {if construction == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="construction[data][]" value="{construction}" {if construction == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="services-group">
                        <td class="title">Logistics / Transportation</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="logistics_transportation[data][]" value="{logistics_transportation}" {if logistics_transportation == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="logistics_transportation[data][]" value="{logistics_transportation}" {if logistics_transportation == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="services-group">
                        <td class="title">Operations &amp; Maintenance</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="operations_maintenance[data][]" value="{operations_maintenance}" {if operations_maintenance == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="operations_maintenance[data][]" value="{operations_maintenance}" {if operations_maintenance == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="services-group">
                        <td class="title">Other Services</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="other_services[data][]" value="{other_services}" {if other_services == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="other_services[data][]" value="{other_services}" {if other_services == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="singleton">
                        <td>Blades / Rotor</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="blades[data][]" value="{blades}" {if blades == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="blades[data][]" value="{blades}" {if blades == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="singleton">
                        <td>Tower</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="tower[data][]" value="{tower}" {if tower == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="tower[data][]" value="{tower}" {if tower == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="singleton">
                        <td>Foundation</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="foundation[data][]" value="{foundation}" {if foundation == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="foundation[data][]" value="{foundation}" {if foundation == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="singleton">
                        <td>Transmission / Electrical</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="transmission_electrical_services[data][]" value="{transmission_electrical_services}" {if transmission_electrical_services == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="transmission_electrical_services[data][]" value="{transmission_electrical_services}" {if transmission_electrical_services == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="singleton">
                        <td>Marine Trades</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="marine_trades[data][]" value="{marine_trades}" {if marine_trades == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="marine_trades[data][]" value="{marine_trades}" {if marine_trades == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                    <tr class="singleton">
                        <td>Research / Academic / Workforce Development</td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="research_academic_workforce_dev[data][]" value="{research_academic_workforce_dev}" {if research_academic_workforce_dev == "current-supply"}checked="yes"{/if}></td>
                        <td><img src="/photos/spacer.gif" alt=""><input type="checkbox" name="research_academic_workforce_dev[data][]" value="{research_academic_workforce_dev}" {if research_academic_workforce_dev == "could-supply"}checked="yes"{/if}></td>
                    </tr>

                </tbody>
            </table>
        </fieldset> 
        <div class="clearer"></div>
        <input type="image" src="/photos/btn_submit-survey.png" alt="" value="Submit">
    </div>
</div><!-- end div.facility-form -->

    {/exp:channel:form}

However, neither one works. What is the correct way to accomplish this?

4
  • Hi again @fmz. Here's a hint to get you started: let EE loop through the checkboxes. See docs: ellislab.com/expressionengine/user-guide/add-ons/channel/… – AllInOne Sep 3 '14 at 14:56
  • Hi AllInOne, this is a very customized form and not one that I believe would work well with the loop. I have edited the question to include the entire form. – forrest Sep 3 '14 at 16:11
  • Isn't it as simple as: <input type="checkbox" name="drivetrain_gearbox" value="current-supply" {if drivetrain_gearbox == "current-supply"}checked="yes"{/if}> – AllInOne Sep 3 '14 at 23:57
  • So what am I missing? – forrest Sep 3 '14 at 23:59
1

Just add a hidden field name called checkbox_fields with list of all checkbox which you use in Channel Forms.

<input type="hidden" name="checkbox_fields" value="checkbox_field_1|checkbox_field_2|checkbox_field_3">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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