1 of 2
1
checkbox not saving
Posted: 20 October 2010 12:37 PM   [ Ignore ]
Wallflower
Rank
Total Posts:  9
Joined  2010-10-18

hi

i want to edit a checkbox in my form

my code looks like this:

{options:mixresp}<label class="checkbox">Doppelfunktion:</label> <input type="checkbox" id="{mixresp}" name="{mixresp}[]" value="{option_value}"{checked} />{/options:mixresp}<br /> 

but i can not save changes (checkboxes)

is my code wrong or do i still need to do this: http://barrettnewton.com/forums/viewthread/760/

using
safecracker - safecracker.1.0.0.build.20101019
ee - 2.1.1. 20101018

many thanks
res

Profile
 
 
Posted: 20 October 2010 06:35 PM   [ Ignore ]   [ # 1 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

Your input name and id should not have curly braces:

{options:mixresp}<label class="checkbox">Doppelfunktion:</label> <input type="checkbox" id="mixresp" name="mixresp[]" value="{option_value}"{checked} />{/options:mixresp}<br /> 
Profile
 
 
Posted: 21 October 2010 12:48 PM   [ Ignore ]   [ # 2 ]
Wallflower
Rank
Total Posts:  9
Joined  2010-10-18

hi rob
thanks for your help. i changed like you said but it didn’t help. checkboxes still will not be saved.

if i do a new entry it works. if i want to edit it doesn’t save.

do you have any idea?

if you need more infos pls. tell me.

btw i updated yesterday your build - but my ee 2.1.1 still shows ‘Safecracker Beta - Build 20101012’ in the cp

thanks again
res

Profile
 
 
Posted: 21 October 2010 05:56 PM   [ Ignore ]   [ # 3 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

OK so now we’re getting somewhere. You say it works fine on new entry, but on edit it doesn’t work. Tell me this, though, does check save on edit? Does uncheck save on edit?

Re: wrong build #. That’s my mistake, I forgot to include the build number on the settings page.

Profile
 
 
Posted: 21 October 2010 06:01 PM   [ Ignore ]   [ # 4 ]
Wallflower
Rank
Total Posts:  9
Joined  2010-10-18

hi rob

uncheck will not save. check will save.

Profile
 
 
Posted: 21 October 2010 06:02 PM   [ Ignore ]   [ # 5 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

One more question: this is a native EE checkbox field, right? Not a 3rd party fieldtype?

Profile
 
 
Posted: 21 October 2010 06:03 PM   [ Ignore ]   [ # 6 ]
Wallflower
Rank
Total Posts:  9
Joined  2010-10-18

yes
native EE checkbox

Profile
 
 
Posted: 21 October 2010 07:48 PM   [ Ignore ]   [ # 7 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

OK here’s a temporary patch to fix this. Open up /system/expressionengine/third_party/safecracker/libraries/safecracker_lib.php.

Around line 1009 you’ll see this block of code:

//
                    
if ($field['field_type'== 'date')
                    
{
                        $_POST[
'field_id_'.$field['field_id']] $_POST[$field['field_name']] $this->EE->localize->set_human_time($this->EE->localize->offset_entry_dst($this->entry($field['field_name']), $this->entry('dst_enabled'), FALSE));
                    
}
                    
else
                    
{
                        $_POST[
'field_id_'.$field['field_id']] $_POST[$field['field_name']] $this->entry($field['field_name']TRUE);
                    

Change line 1009:

else 

To this:

else if ($field['field_type'!= 'checkboxes'
Profile
 
 
Posted: 21 October 2010 07:59 PM   [ Ignore ]   [ # 8 ]
Wallflower
Rank
Total Posts:  9
Joined  2010-10-18

hi rob

great! this works perfect!

this is a wonderful support - thank you very much!
res

Profile
 
 
Posted: 27 October 2010 02:58 AM   [ Ignore ]   [ # 9 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

Hi—I just wanted to add a note here for anyone who’s interested, regarding SafeCracker and checkbox fields. Please check: http://barrettnewton.com/safecracker/user_guide/entry_form/#par_preserve_checkboxes

Profile
 
 
Posted: 05 November 2010 08:33 PM   [ Ignore ]   [ # 10 ]
Wallflower
Rank
Total Posts:  9
Joined  2010-10-18

hi rob

updated today to the newest build safecracker.1.0.0.build.20101102

now i cannot see any checkboxes anymore in my form.

get an errormessage:

Severity: Warning
Message: preg_match() expects parameter 2 to be string, array given
Filename: safecracker_file/ft.safecracker_file.php
Line Number: 65

and

Message: Cannot modify header information - headers already sent by (output started at /home/xy/public_html/stats/system/codeigniter/system/core/Exceptions.php:171)
Filename: core/Common.php
Line Number: 424

and i saw in another thread an example for checkboxes where you had curly brackets in the checkbox-example
http://barrettnewton.com/forums/viewthread/853/

Custom Fields

      {options:your_checkbox_field_name}
        <label class=“checkbox”>{option_value} <input type=“checkbox” id=”{field_name}” name=”{field_name}[]” value=”{option_value}”{checked} /></label>
      {/options:your_checkbox_field_name}
      {field:your_matrix_field_name}
      {field:your_wygwam_field_name}
{/custom_fields}

can you help me?

thanks
res

Profile
 
 
Posted: 05 November 2010 08:37 PM   [ Ignore ]   [ # 11 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

Your field name should not have curly braces, unless you are within a custom_fields loop. You should use the name of the field for your field name and id.

Someone else reported that preg_match error, I’m looking into it. Can you PM me access to your site?

Profile
 
 
Posted: 05 November 2010 08:40 PM   [ Ignore ]   [ # 12 ]
Wallflower
Rank
Total Posts:  9
Joined  2010-10-18

ok

half of problem solved.
php errors gone. name/title of upload destination was missing.

do you still need access to the site?

res

[ Edited: 05 November 2010 08:43 PM by verveuster ]
Profile
 
 
Posted: 05 November 2010 09:16 PM   [ Ignore ]   [ # 13 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

Can you show me your template code?

Profile
 
 
Posted: 08 November 2010 03:44 PM   [ Ignore ]   [ # 14 ]
Wallflower
Rank
Total Posts:  9
Joined  2010-10-18

thank you rob!

my fault: i forgot that it is required to add at least one option like y or Ja to make the options work.

If i want the option name to print i have to use the option_name tag.

Profile
 
 
Posted: 31 March 2011 04:22 PM   [ Ignore ]   [ # 15 ]
Wallflower
Rank
Total Posts:  4
Joined  2011-02-15

I got a similar problem with version 1.0.3 checkbox on edit when switching for checked to unchecked will not get saved. Is this workaround still necessary ?
Thx Felix

Profile
 
 
   
1 of 2
1