Skip to content

Commit

Permalink
Should fix #18
Browse files Browse the repository at this point in the history
Wasn’t catering for fields without an existing ID (new fields), now
corrected.
  • Loading branch information
Nathan Pitman committed Sep 23, 2014
1 parent a985112 commit 371836d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions system/third_party/nf_categories_field/ft.nf_categories_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,16 @@ function save_settings($settings)
$settings['field_show_fmt'] = 'n';
$settings['field_type'] = 'nf_categories_field';

$field_name = "field_id_".$settings['field_id'];

if ($settings['sync_cats']) {
ee()->db->where($field_name, '');
ee()->db->update('channel_data', array($field_name => 'EMPTY'));
} else {
ee()->db->where($field_name, 'EMPTY');
ee()->db->update('channel_data', array($field_name => ''));
// Only set the empty field value for existing fields
if(!empty($settings['field_id'])) {
$field_name = "field_id_".$settings['field_id'];
if ($settings['sync_cats']) {
ee()->db->where($field_name, '');
ee()->db->update('channel_data', array($field_name => 'EMPTY'));
} else {
ee()->db->where($field_name, 'EMPTY');
ee()->db->update('channel_data', array($field_name => ''));
}
}

return $settings;
Expand Down

0 comments on commit 371836d

Please sign in to comment.