title: Adding Select Field to Bootstrap Form and Getting it to Post to Database in Laravel Project
body: <p>I am using Laravel and trying to add a new select field to the standard Bootstrap registration form. I cannot get the value specified in the select field to show up in my database after submitting the form. All of the other fields (e.g., user name and email) are working fine.</p>
  
  <p>Below is a portion of the code with some fields removed for brevity. All I've done is add the select field without altering any code in other Laravel files. The DB has two tables. One is called institutions, which has two columns: "name" and "instid" (primary key). The other is called users, which has several columns, one of which is "instid" (foreign key). This foreign key field is the one to which I would like to post the selected value.</p>
  
  <p>How do I get the value specified in the select field to show up in my database after submitting the form?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>@extends('layouts.app')
  
  @section('content')
  &lt;div class="container"&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-md-8 col-md-offset-2"&gt;
              &lt;div class="panel panel-default"&gt;
                  &lt;div class="panel-heading"&gt;Register&lt;/div&gt;
                  &lt;div class="panel-body"&gt;
                      &lt;form class="form-horizontal" role="form" method="POST" action="{{ url('/register') }}"&gt;
                          {!! csrf_field() !!}
  
                          &lt;div class="form-group{{ $errors-&gt;has('name') ? ' has-error' : '' }}"&gt;
                              &lt;!-- use for="name" so that clicking on label places cursor in input field with id="name" --&gt;
                              &lt;label class="col-md-4 control-label" for="name"&gt;Name&lt;/label&gt;
  
                              &lt;div class="col-md-6"&gt;
                                  &lt;input type="text" class="form-control" id="name" name="name" value="{{ old('name') }}"&gt;
  
                                  @if ($errors-&gt;has('name'))
                                      &lt;span class="help-block"&gt;
                                          &lt;strong&gt;{{ $errors-&gt;first('name') }}&lt;/strong&gt;
                                      &lt;/span&gt;
                                  @endif
                              &lt;/div&gt;
                          &lt;/div&gt;
  
                          &lt;div class="form-group{{ $errors-&gt;has('email') ? ' has-error' : '' }}"&gt;
  
                          &lt;div class="form-group"&gt;
                              &lt;label class="col-md-4 control-label" for="instid"&gt;Institution&lt;/label&gt;
  
                              &lt;div class="col-md-6"&gt;
                                  &lt;select class="form-control" id="instid" name="instid" required="required"&gt;
                                      &lt;option value="" selected disabled&gt;Choose an institution.&lt;/option&gt;
                                      &lt;?php
                                          $institutions = App\Institution::all();
                                          foreach($institutions as $institution){
                                              echo "&lt;option value=\"" . $institution-&gt;instid . "\"&gt;" . $institution-&gt;name . "&lt;/option&gt;";
                                          }
                                      ?&gt;
                                  &lt;/select&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
    
                          &lt;div class="form-group"&gt;
                              &lt;div class="col-md-6 col-md-offset-4"&gt;
                                  &lt;button type="submit" class="btn btn-primary"&gt;
                                      &lt;i class="fa fa-btn fa-user"&gt;&lt;/i&gt;Register
                                  &lt;/button&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/form&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  @endsection</code></pre>
  </div>
  </div>
  </p>