0

Hi i'm using laravel collective, im trying to load the selected default value from the datbase

// $ring->homepage
// holds 0 or 1
{!! Form::select('onhome', [0 => 'Nee', 1 => 'Ja'], null, ['class' => 'form-control selectpicker']) !!}

According to the documentation this should work

{!! Form::select('onhome', [0 => 'Nee', 1 => 'Ja'], $ring->homepage, ['class' => 'form-control selectpicker']) !!}

But it's not working

enter image description here

It still shows 0 => 'Nee' while it is 1 => 'Ja'

Am i doing something wrong?

Rubberduck1337106092
  • 1,294
  • 5
  • 21
  • 38
  • Are you opening your form with Form::model as described in the documentation? You need to use form model binding for it to auto populate from the database https://laravelcollective.com/docs/5.1/html#form-model-binding – Rob Fonseca Jul 14 '16 at 11:12

1 Answers1

0

The value matches, but the key doesn't. The key has to match with the value in $ring->homepage, so you either have to change the keys to 'Ja' and 'Nee', or the value $ring->homepage to an integer (0 or 1 in this case).

piscator
  • 8,028
  • 5
  • 23
  • 32