Add theme settings field to theme-settings.php in d8 is not working for me I followed the documentation on drupal.org to add a field to the theme-settings.php but there must be a mistake in code. 

I have a filed called advertisement and a theme called tv so I tried to copy and paste the code and altered the names where to alter theme the files I created in particular are as follows:

/themes/tv/templates/system/thme-settings.php

#}
function tv_form_system_theme_settings_alter(&amp;$form,      
\Drupal\Core\Form\FormStateInterface &amp;$form_state, $form_id = NULL) {
  // Work-around for a core bug affecting admin themes. See issue     
 #943212.
  if (isset($form_id)) {
    return;

$form['tv_advertisement'] = array(
    '#type'          =&gt; 'textfield',
    '#title'         =&gt; t('Widget'),
    '#default_value' =&gt; theme_get_setting('tv_advertisement'),
    '#description'   =&gt; t("Place this text in the widget spot on your     
 site."),
  );
}
$tv_advertisement = theme_get_setting('tv_advertisement');


in /themes/tv/config/install/tv.settings.yml I put this:

tv_advertisement: blue bikeshed


My /themes/tv/tv.theme file contains:

&lt;?php
/**
 * @file
 * Theme functions
 */

// Include all files from the includes directory.
$includes_path = dirname(__FILE__) . '/includes/*.inc';
foreach (glob($includes_path) as $filename) {
  require_once dirname(__FILE__) . '/includes/' . basename($filename);
}

 function tv_preprocess_node(&amp;$variables) {
 $variables['tv_advertisement'] =     
 theme_get_setting('tv_advertisement');
 }


The last thing I did was 

drush cr 


to clear the cache

When I go to the themes settings page there are only the default fieds displayed but the new one does not show up

If anyone has a clue what I am doing wrong and is able to enlighten me I would be very pleased.

Thank you
Try to remove this code:


  if (isset($form_id)) {
    return;


The hook interface of hook_form_system_theme_settings_alter is hook_form_system_theme_settings_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state).

You can remove the third parameter:


 $form_id = NULL