Some checkboxes saving, some not
Posted: 03 September 2010 10:23 PM   [ Ignore ]
Wallflower
Avatar
Rank
Total Posts:  30
Joined  2010-08-10

When I save an entry after checking off checkboxes, some save and some don’t, seemingly sparatic. For example I check 3 boxes and only one saves. This is happening on 2 different fields.

Here is the code for one, possibly i miscoded?

<label class="desc" id="title261" for="Field261">Do you believe your employer treated you differently for any of the following reasons? (check all that apply)</label>
    <
div>
    
{options:cef_discriminations_reasons}
        
<span>
            <
input type="checkbox" name="cef_discriminations_reasons[]" class="field checkbox" value="{option_value}"{checked} />
            <
label class="choice">{option_value}</label
        </
span>
    
{/options:cef_discriminations_reasons}
     
</div
Profile
 
 
Posted: 03 September 2010 10:38 PM   [ Ignore ]   [ # 1 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

It’s just a standard EE Checkboxes field? Your code look OK to me.

I have noticed a bug, if I uncheck all of them, it doesn’t save properly, but otherwise it does. Is that what you’re noticing?

As a test, edit/create an entry, and go check it in the CP, did it save properly there and is just not showing up properly on the SAEF? Or maybe it’s not saving properly at all?

Profile
 
 
Posted: 07 September 2010 08:27 PM   [ Ignore ]   [ # 2 ]
Wallflower
Avatar
Rank
Total Posts:  30
Joined  2010-08-10

It’s just a standard EE Checkboxes field.

You are right, when I uncheck all of them, nothing saves. When I check all of them, only one saves. In the cp, the changes are not there, so it looks like they are not saving properly at all.

Profile
 
 
Posted: 07 September 2010 08:58 PM   [ Ignore ]   [ # 3 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

I’m at a loss, because I can’t duplicate these results (checkboxes work on my setup). Any chance we can get site access?

Profile
 
 
Posted: 08 September 2010 12:09 AM   [ Ignore ]   [ # 4 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

For some reason, your options had an extra space at the end of them, so when the checkbox printed out, it was like:

value="Termination " 

So when you submitted, it saw that you submitted a value that didn’t match exactly, and got rid of it. I don’t know why the extra space was being added, it could possibly have something to do with the server environment. As a fix, I added a trim() around the values to remove an extraneous spaces.

With regard to the “bug” where if you uncheck all of them, it doesn’t save: add a blank, hidden input.

<input type="hidden" name="cef_discriminations_reasons[]" value="" /> 
Profile
 
 
Posted: 08 September 2010 01:13 AM   [ Ignore ]   [ # 5 ]
Wallflower
Avatar
Rank
Total Posts:  30
Joined  2010-08-10

I would bet the space at the end of the option was a copy and paste thing. Thanks for tracking that down. I added the hidden input and things are working properly. Thanks.

Profile