Input sanitised option_value
Posted: 02 October 2010 03:03 PM   [ Ignore ]
Wallflower
Rank
Total Posts:  11
Joined  2010-09-21

Hello,

I’m running up against a ‘Disallowed Key Characters’ error which is being thrown by /system/codeigniter/system/core/Input.php and the reason this is happening is that EE sanitises a string on SAEF/Safecracker input.

I’m using {option_value} to build the checkbox array as it’s a multi select checkbox - my {option_value} contains spaces which is triggering the ‘Disallowed Key Characters’ error.

{options:reg_q5}
        {option_name}
     
<input name="reg_q5[{option_value}]" type="checkbox" value="{option_value}" {checked} /><br />
    
{/options:reg_q5} 

A good addtion to Safecracker would be a sanitised {option_name} placeholder so that it adheres to the function _clean_input_keys in ‘/system/codeigniter/system/core/Input.php’

Thanks
John

[ Edited: 19 October 2010 03:25 AM by Rob Sanchez ]
Profile
 
 
Posted: 02 October 2010 07:38 PM   [ Ignore ]   [ # 1 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

Forgive me if I’m being dense, but I don’t think you need to include {option_value} in the input name. Couldn’t you just do this?

{options:reg_q5}
   {option_name}
   
<input name="reg_q5[]" type="checkbox" value="{option_value}" {checked} /><br />
{/options:reg_q5} 

And which type of field are you using Checkboxes or PT Checkboxes?

Profile
 
 
Posted: 02 October 2010 09:41 PM   [ Ignore ]   [ # 2 ]
Wallflower
Rank
Total Posts:  11
Joined  2010-09-21

You know what…I’ve been coding my checkbox arrays like that for years and never realised I could just leave it blank.

Tried and working.

Thanks
John

Profile
 
 
   
 
 
‹‹ Auto-submit      List categories in order ››