Search code examples
phphtmltwitter-bootstraplaravellaravel-5.3

failing to display the data in the edit form : laravel


when I using model like this :

<div class="form-group col-sm-6">
        {!! Form::label('nop3', 'Nop3:') !!}
        {!! Form::text('nop3', null, ['class' => 'form-control']) !!}
    </div>

data nop3 can be displayed in textfield nop3 : https://postimg.org/image/x4ar40u7b/

but, I using model like this :

<div class="form-group col-sm-6">
    <div class="form-group col-sm-3">
        NOMOR P3
    </div>
    <div class="form-group col-sm-9">
        <input type="text" name="nop3" class="form-control">
    </div>
</div>

data nop3 can not be displayed in textfield nop3 : https://postimg.org/image/jin2ns0y9/

whereas these two models the same

if anyone can explain to me?


Solution

  • Your assumption, that the two approaches you showed in your question are the same, is wrong!

    When using the Form helper class, there are a lot things that work behind the scenes.

    If you decide not to use the helper classes, you need to populate your form manually!

    It can look like this:

    <div class="form-group col-sm-6">
        <div class="form-group col-sm-3">
            NOMOR P3
        </div>
        <div class="form-group col-sm-9">
            <input type="text" name="nop3" class="form-control" value="{{$nop3}}">
        </div>
    </div>