I'm using Drupal 5.2, and install 5.x-1.x-dev, no setting or add some Default filter settings.
After that adding content I've got the error:

Fatal error: Cannot unset string offsets in ../sites/all/modules/default_filter/default_filter.module on line 221

Comments

freixas’s picture

The problem occurs because only the numeric keys in the format_key array have an index of '#value'.

This is my fix to the code:

                if(array_key_exists($format_key, $form['body_filter'])){
                        //Unset any pre-selected filter. If multiples are checked, Gecko
                        //browsers seem to take the last selected but IE takes the first selected.
                        foreach($form['body_filter'][$format_key] as $key => $val){
                            // Fixes by AF
                            if (is_numeric($key)) {
                                if (isset($form['body_filter'][$format_key][$key]['#value'])) {
                                    unset($form['body_filter'][$format_key][$key]['#value']);
                                }
                                if (isset($form['body_filter'][$format_key][$key]['#default_value'])) {
                                    unset($form['body_filter'][$format_key][$key]['#default_value']);
                                }
                            }
                        }

                        if($format > 0 && isset($form['body_filter'][$format_key][$format])){
                                $form['body_filter'][$format_key][$format]['#value'] = $format;
                        }
                }
dllh’s picture

Thanks for this fix. I've committed to HEAD.

dllh’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)