title: Is get_field_id() Necessary for Form Filed in WordPress Widget API?
body: <p>I'm trying to create a custom widget for my plugin and following <a href="http://codex.wordpress.org/Widgets_API" rel="nofollow">the codex</a>.</p>
  
  <p>This is what I have so far. It's working and saves and displays the saved option value.</p>
  
  <pre><code>&lt;?php
  /**
   * Plugin Name: Sample Widget
   */
  
  $colors = array('red', 'blue', 'yellow');
  update_option('sample_widget', $colors);
  
  add_action( 'widgets_init', create_function( '', 'register_widget( "Sample_Widget" );' ) );
  class Sample_Widget extends WP_Widget {
  
      public function __construct() {
          parent::__construct(
              'foo_widget', 
              'Sample Widget', 
              array( 'description' =&gt; __( 'This is a description of the sample widget', 'text_domain' ), ) // Args
          );
      }
  
      public function widget( $args, $instance ) {
          extract( $args );
          $title = apply_filters( 'widget_title', $instance['title'] );
          $color = apply_filters( 'widget_title', $instance['color'] );
  
          echo $before_widget;
          if ( ! empty( $title ) )
              echo $before_title . $title . $after_title;
          echo 'the selected color is ' . $color . '&lt;br /&gt;';
          echo $after_widget;
      }
  
      public function update( $new_instance, $old_instance ) {
          $instance = array();
          $instance['title'] = strip_tags( $new_instance['title'] );
          $instance['color'] = $new_instance['color'];
          return $instance;
      }
  
      public function form( $instance ) {
          if ( isset( $instance[ 'title' ] ) ) {
              $title = $instance[ 'title' ];
          }
          else {
              $title = __( 'New title', 'text_domain' );
          }
          if ( isset( $instance[ 'color' ] ) ) {
              $selected_color = $instance[ 'color' ];
          }
          $colors = get_option('sample_widget');
          ?&gt;
          &lt;p&gt;
              &lt;label for="&lt;?php echo $this-&gt;get_field_id( 'title' ); ?&gt;"&gt;&lt;?php _e( 'Title:' ); ?&gt;&lt;/label&gt; 
              &lt;input class="widefat" id="&lt;?php echo $this-&gt;get_field_id( 'title' ); ?&gt;" name="&lt;?php echo $this-&gt;get_field_name( 'title' ); ?&gt;" type="text" value="&lt;?php echo esc_attr( $title ); ?&gt;" /&gt;
          &lt;/p&gt;
          &lt;p&gt;
              &lt;select name="&lt;?php echo $this-&gt;get_field_name( 'color' ); ?&gt;" id="&lt;?php echo $this-&gt;get_field_id( 'color' ); ?&gt;"&gt;
                  &lt;option value=""&gt;Select...&lt;/option&gt;
                  &lt;?php foreach($colors as $color) echo '&lt;option value="' . esc_attr( $color ) . '" ' . ($color == $selected_color ? 'selected="Selected"' : '') .  '&gt;'. $color .'&lt;/option&gt;'; ?&gt;
              &lt;/select&gt;
          &lt;/p&gt;
          &lt;?php 
      }
  } 
  </code></pre>
  
  <p>I have two questions:</p>
  
  <ol>
  <li>What is <code>id="&lt;?php echo $this-&gt;get_field_id( 'color' ); ?&gt;"</code> for? I removed this part of the line and it seems to work fine. I placed it to just copy the codex working code.</li>
  <li>In the constructor, the first parameter in <code>parent::__construct()</code> is a base ID. Could this be any string value? I changed it to something else from <code>foo_widget</code> and it seems to work. </li>
  </ol>
  
  <p>Thanks for your info.</p>