1

I have this controller who grab the two text fiel values that the user enter before clicking save. Everything going good till i check the values.. nothing happen it seems that the input request doesn't work

Where i'm doing wrong ? i don't get the values entered for "resultat_domicile" and "resultat_visiteur" . thanks a lot in advance if someone could help

here the controller :

public function addResultat(Request $request  , $id){

        $rencontre = Rencontre::findOrFail($id);

        $rencontre->resultat_domicile = $request->input('resultat_domicile');
        $rencontre->resultat_visiteur = $request->input('resultat_visiteur');

        dd($rencontre);

    }

here my view :

 {!!  Form::open(array('route' => array('add.resultat', $rencontre->id)))!!}

                @foreach($rencontres as $rencontre)


                    <div class="box-body">
                        <div class="row">
                            <div class="col-md-4"></div>
                            <div class="col-md-4 text-center">
                                <p class="h4">{{$rencontre->compet->lb_compet}}</p>
                                <p class="h4 text-light-blue">{{\Carbon\Carbon::parse($rencontre->dt_rencontre)->format('d/m/Y')}}</p>
                                <br>
                            </div>
                            <div class="col-md-4"></div>
                        </div>
                        <div class="row">
                            <div class="col-md-5">
                                <h2 class="pull-right"><div class="fa fa-shield pull-right"></div>{{$rencontre->equipe_domicile->lb_equipe}}</h2>
                            </div>
                            <div class="col-md-2">
                                <div class="row">
                                    <div class="col-xs-5">
                                        {!! Form::text('resultat_domicile', null ,  ['class' => 'form-control', 'placeholder' => 'Ex: 20 points']) !!}

                                    </div>
                                    <div class="col-xs-2 text-center">
                                        <span class="h2">-</span>
                                    </div>
                                    <div class="col-xs-5">
                                        {!! Form::text('resultat_visiteur', null ,  ['class' => 'form-control', 'placeholder' => 'Ex: 20 points']) !!}
                                    </div>

                                </div>
                            </div>
                            <div class="col-md-5">
                                <h2 class="pull-left"><div class="fa fa-shield pull-left"></div>{{$rencontre->equipe_visiteur->lb_equipe}}</h2>
                            </div>
                        </div>


                        @endforeach

                        <div class="box-footer">
                            <div class="col-xs-12 text-center">
                                {!! Form::submit('Enregistrer', ['class' => 'btn btn-info btn-lg center-block']) !!}
                                {!! Form::close() !!}
                            </div>
                        </div>
1
  • Try dd($request->resultat_domicile); and see what happens. Let me know if that gave the result Commented Apr 26, 2017 at 15:29

1 Answer 1

1

I assume you've shown complete view. You need to submit the form to get values, but you're just creating a simple link.

Make sure you're opening the form with Form::open() and submitting the form with submit button, like Form::submit()

Sign up to request clarification or add additional context in comments.

6 Comments

sorry haha !!!! i forgot to try this . thanks i updated the code if someone have the same problem . thanks a lot again
the only problem now when i click on save i get the value but if i have many ids it's take only the first one ! it's seems my foreach is not in the right place
i mean it's look like a form inside a loop and when i click on save , all the button is clicked in the save time and i get only the first object , i would like to save on each object inside the loop
Then move the form's open and close tags and submit button outside the loop. Also, change text field names to something like resultat_domicile[]. In a controller you'll get arrays then.
if i move the form open with $rencontre->id i get Undefined variable: rencontre .
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.