jeudi 15 mars 2018

Laravel input form inside @foreach

I'm stuck. I have a little problem. When i using @foreach input fields are disaper . Have any ideas?) I just rebuild model, so i need get values now using foreach.

Controller method:

 public function show($id)
    {
        // get the coral
     $coral = Coral::with('coralColors')->find($id);
        // show the view and pass the coral to it
     return View::make('coral.coralShow',compact('coral','id'));
    }

View blade:

{!! Form::model($coral,['method'=>'POST'])!!} 
    
        {!!Form::hidden('coral_id',$id)!!}
<table class="table table-bordered">
    <tr>
    <th>BlueRidge</th>
    <th>Blue</th>
    <th>Brick</th>
    <th>Yellow</th>
    <th>Red</th>
    <th>Orange</th>
    <th>Green</th>
    <th>Turquoise</th>
    <th>Purple</th>
    <th>Pink</th>
    <th>Mustard</th>
    <th>Summary</th>
    </tr>
    <tr>
    @foreach($coral->coralColors as $cc)
    <td>{!!Form::number('blueridge',$cc->bluerige,null,array('style'=>'width:50px'))!!}</td>
    <td>{!!Form::number('blue',$cc->blue,null,array('style'=>'width:50px'))!!}</td>
    <td>{!!Form::number('brick',$cc->brick,null,array('style'=>'width:50px'))!!}</td>
    <td>{!!Form::number('yellow',$cc->yellow,null,array('style'=>'width:50px'))!!}</td>
    <td>{!!Form::number('dark_red',$cc->dark_red,null,array('style'=>'width:50px'))!!}</td>
    <td>{!!Form::number('orange',$cc->orange,null,array('style'=>'width:50px'))!!}</td>
    <td>{!!Form::number('green',$cc->greeb,null,array('style'=>'width:50px'))!!}</td>
    <td>{!!Form::number('turquoise',$cc->turquoise,null,array('style'=>'width:50px'))!!}</td>
    <td>{!!Form::number('purple',$cc->purple,null,array('style'=>'width:50px'))!!}</td>
    <td>{!!Form::number('pink',$cc->pink,null,array('style'=>'width:50px'))!!}</td>
    <td>{!!Form::number('mustard',$cc->mustard,null,array('style'=>'width:50px'))!!}</td>
    <td></td>
    @endforeach
    <tr>
</table>
<div class="col-xs-12 col-sm-12 col-md-12 text-center">
    <button type="submit" class="btn btn-primary">Submit</button>
</div>
{!! Form::close() !!}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire