title: laravel dropdown with database
body: <p>i'm a newbie to laravel framework and i just find it's so hard to understanding laravel form usability.... so here is some issue that i face into</p>
  
  <p><strong>First</strong> my dropdown should be having my categories name and at the very end of dropdown it will be my specific dropdown add new categories that when i selected will trigger my javascript... and im here is my form code</p>
  
  <pre><code>{{ Form::select('kategori',KategoriArtikel::lists('name','id'),Input::old('kategori'),array('class' =&gt; 'form-control', 'onChange' =&gt; 'changeFunc(value)')) }}
  </code></pre>
  
  <p>that will show right value from my database also with right selected value but it's missing my specific dropdown, so i tried to add like this </p>
  
  <pre><code> &lt;?php 
       $tambah = array('tambah' =&gt; 'Tambah Kategori Baru');
       $list = array_merge(KategoriArtikel::lists('name','id'),$tambah); 
   ?&gt;
  {{ Form::select('kategori',array(KategoriArtikel::lists('name','id'),$tambah),Input::old('kategori'),array('class' =&gt; 'form-control', 'onChange' =&gt; 'changeFunc(value)')) }}
  </code></pre>
  
  <p>but it will generate 2  with different layout (which ugly) and not showing right selected value, so i tried other way</p>
  
  <pre><code> &lt;?php 
       $tambah = array('tambah' =&gt; 'Tambah Kategori Baru');
       $list = array_merge(KategoriArtikel::lists('name','id'),$tambah); 
  ?&gt;
  {{ Form::select('kategori',$list,Input::old('kategori'),array('class' =&gt; 'form-control', 'onChange' =&gt; 'changeFunc(value)')) }}
  </code></pre>
  
  <p>and it not generate  and my dropdown layout is what it supposed to be but now the  is not from my table id anymore but just sequential number 0,1,2,3,etc
  any solution to that?</p>
  
  <p><strong>Second</strong> problem is when i submit my form, it's not working, my field in table is int and when i submit it just not saving/updating so i tried to dd(Input::all()) and my dropdown is returning string of selected option value and it's not saved into my table... so why is that? it also not working for my boolean field that contain tinyint(1)... so basicly all value returning string.</p>
  
  <p>its returning this</p>
  
  <pre><code>array(8) { ["_method"]=&gt; string(3) "PUT" ["_token"]=&gt; string(40) "IspUKdCETMe4Nn3pDI43GI7aJKQfXpupJvQAy1k6" ["simpan"]=&gt; string(6) "simpan" ["judul"]=&gt; string(18) "test "kegiatan" 21" ["kategori"]=&gt; string(1) "9" ["kategori_baru"]=&gt; string(0) "" ["status"]=&gt; string(1) "0" ["content"]=&gt; string(1012) "
  I used--and I don't put my arm round your waist,' the Duchess said to herself. 'Of the mushroom,' said the Dormouse, and repeated her question. 'Why did they live at the sides of it, and then turned to the tarts on the twelfth?' Alice went on, 'that they'd let Dinah stop in the shade: however, the moment he was obliged to have wondered at this, but at the Caterpillar's making such a capital one for catching mice--oh, I beg your pardon!' cried Alice hastily, afraid that she had read about them in books, and she at once without waiting for turns, quarrelling all the children she knew, who might do something better with the time,' she said to herself; 'I should like to drop the jar for fear of killing somebody, so managed to swallow a morsel of the house, quite forgetting her promise. 'Treacle,' said the Gryphon: and it sat for a few minutes to see if she had grown up,' she said this, she looked down at her as she wandered about for it, you know--' (pointing with his head!' she said,.
  
  " }
  </code></pre>
  
  <p>and as you can see ['kategori'] is supposed to be making my field kategori in my table to be 9 but it's not changing anything in my database</p>
  
  <p>well i laravel simplicity but it's very confusing when working with database (can't find any documentation example related to databas retrieving data and so on)</p>
  
  <p>edit:</p>
  
  <p>this is my controller</p>
  
  <pre><code>public function update($id)
  {
      $artikel = Artikel::findOrFail($id);
  
      if(Input::get('simpan')){
          //dd(Input::all());
  
          $validator = Validator::make($data = Input::all(), Artikel::$rules);
  
          if ($validator-&gt;fails())
          {
              return Redirect::back()-&gt;withErrors($validator)-&gt;withInput();
          }
  
          $judul = Input::get('judul');
          $artikel-&gt;update($data);
  
          return Redirect::route('admin.artikels.index')-&gt;with('message', 'Artikel ' .$judul. ' Telah berhasil di ubah.');
      }elseif(Input::get('batal')){
          return $this-&gt;index();
      }
  }
  </code></pre>
  
  <p>and here is my view</p>
  
  <pre><code>@extends('admin._layouts.admin')
  
  @section('content')
  {{ Form::model($artikel, array('route' =&gt; array('admin.artikels.update',$artikel-&gt;id), 'method' =&gt; 'put')) }}
      &lt;div class="panel panel-default"&gt;
          &lt;!--button--&gt;
          &lt;div class="panel-heading tooltip-demo"&gt;
              {{ Form::submit('Simpan',array('class' =&gt; 'btn btn-primary', 'data-toggle' =&gt; 'tooltip', 
                 'data-placement' =&gt; 'top','title' =&gt; 'Menyimpan artikel' )) }}
              {{ Form::submit('Batal',array('class' =&gt; 'btn btn-default', 'data-toggle' =&gt; 'tooltip', 
                 'data-placement' =&gt; 'top','title' =&gt; 'Batal menambah artikel dan kembali ke halaman kelola artikel' )) }}
          &lt;/div&gt;
          &lt;!--/button--&gt;
          &lt;div class="panel-body"&gt;
              &lt;!--judul--&gt;
              &lt;div class="col-lg-10"&gt;
              &lt;div class="form-group"&gt;
                  {{ Form::label('Judul Artikel') }}
                  {{ Form::text('judul',null,array('class' =&gt; 'form-control', 'placeholder' =&gt; 'Silahkan masukkan judul artikel'))}}
                  {{ $errors-&gt;first('judul', '&lt;p class="error"&gt;:message&lt;/p&gt;') }}
              &lt;/div&gt;
              &lt;/div&gt;
              &lt;!--/judul--&gt;
              &lt;!--kategori--&gt;
              &lt;div class="col-lg-4"&gt;
              &lt;div class="form-group"&gt;
                  {{ Form::label('Kategori') }}
                  &lt;?php 
                      $tambah = array('tambah' =&gt; 'Tambah Kategori Baru');
                      $list = array_merge(KategoriArtikel::lists('name','id'),$tambah); 
                  ?&gt;
                  {{ Form::select('kategori',$list,'Pilih Kategori Artikel',array('class' =&gt; 'form-control', 'onChange' =&gt; 'changeFunc(value)')) }}
              &lt;/div&gt;
              &lt;/div&gt;
              &lt;!--/kategori--&gt;
              &lt;!--kategori baru--&gt;
              &lt;div class="col-lg-4"  id="pilihan" style="display:none;"&gt;
              &lt;div class="form-group"&gt;
                  {{ Form::label('Kategori Baru') }}
                  {{ Form::text('kategori_baru',null,array('class' =&gt; 'form-control', 'placeholder' =&gt; 'Silahkan masukkan kategori baru', 
                     'maxlength' =&gt; '30'))}} 
              &lt;/div&gt;
              &lt;/div&gt;
              &lt;!--/kategori baru--&gt;
              &lt;!--status--&gt;
              &lt;div class="col-lg-4"&gt;
              &lt;div class="form-group"&gt;
                  {{ Form::label('Status') }}
                  {{ Form::select('status',array('0' =&gt; 'Tidak diterbikan', '1' =&gt; 'Terbitkan'),null, array('class' =&gt; 'form-control')) }}
              &lt;/div&gt;
              &lt;/div&gt;
              &lt;!--/status--&gt;
              &lt;!--artikel pilihan--&gt;
              &lt;div class="col-lg-5"&gt;
              &lt;div class="form-group"&gt;
                  {{ Form::label('Artikel Pilihan') }}
                  &lt;div class="input-group"&gt;
                  &lt;span class="input-group-addon"&gt;
                  {{ Form::checkbox('pilihan','1',true,array('id' =&gt; 'artikelpilihan')) }}
                  &lt;/span&gt;
                  {{ Form::text('null','Tidak',array('class' =&gt; 'form-control', 'id' =&gt; 'artikeltext' ,'disabled' =&gt; 'true'))}}
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;/div&gt;
              &lt;!--/artikel pilihan--&gt;
              &lt;!--content--&gt;
              &lt;div class="col-lg-12"&gt;
                  {{ Form::label('Isi Artikel') }}
                  {{ Form::textarea('content',null,array('style' =&gt; 'height:300px')) }}
                  {{ $errors-&gt;first('content', '&lt;p class="error"&gt;:message&lt;/p&gt;') }}
              &lt;/div&gt;
              &lt;!--/content--&gt;
          &lt;/div&gt;
       &lt;/div&gt;
  {{ Form::close() }}
  {{ HTML::script('js/tinymce/tinymce.min.js') }}
  &lt;script type="text/javascript"&gt;
      tinymce.init({
          selector: "textarea",
          theme: "modern",
          skin: 'light',
          plugins: [
              "advlist autolink lists link image charmap print preview hr anchor pagebreak",
              "searchreplace wordcount visualblocks visualchars code fullscreen",
              "insertdatetime media nonbreaking save table contextmenu directionality",
              "emoticons template paste textcolor colorpicker textpattern"
          ],
          toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
          toolbar2: "print preview media | forecolor backcolor emoticons | fontselect fontsizeselect",
          image_advtab: true,
          templates: [
              {title: 'Test template 1', content: 'Test 1'},
              {title: 'Test template 2', content: 'Test 2'}
          ],
          file_browser_callback: RoxyFileBrowser
      });
  
  
      function RoxyFileBrowser(field_name, url, type, win) {
        var roxyFileman = '../../../../public/js/tinymce/plugins/fileman/index.html?integration=tinymce4';
        if (roxyFileman.indexOf("?") &lt; 0) {     
          roxyFileman += "?type=" + type;   
        }
        else {
          roxyFileman += "&amp;type=" + type;
        }
        roxyFileman += '&amp;input=' + field_name + '&amp;value=' + document.getElementById(field_name).value;
        tinyMCE.activeEditor.windowManager.open({
           file: roxyFileman,
           title: 'File Manager',
           width: 800, 
           height: 480,
           resizable: "yes",
           plugins: "media",
           inline: "yes",
           close_previous: "no"  
        }, {     window: win,     input: field_name    });
        return false; 
      }
  &lt;/script&gt;
  @stop
  </code></pre>