mercredi 25 novembre 2015

Laravel 5 Same value for each input

Hello and here is my problem.

I have a hidden field on my form for registering candidates that supplies a purchance_order_number to a candidate which is generated using:$purchase_order_number = Str::quickRandom(7); In the create view. I will hopefully use this to group candidates later on.

As more than once candidate can be registered at once I would like the value of this hidden field to be inputted for each candidate. I have tried several things but with no success.

Here is the controller for my create view:

public function centreQualification($id)
{
    $centre = Centre::with('sites')->find($id);

    $purchase_order_number = Str::quickRandom(7);

    return view('vault.create', compact('centre','purchase_order_number'));
}

and here is the view itself:

@extends('app')

@section('content')

    <h1>Register New Candidates</h1>

    <hr/>

    {!! Form::open(['url' => 'candidates', 'name' =>  'candidate_registration_form', 'id' =>  'candidate_registration_form'] ) !!}

    {!! Form::label('qualification_id','Qualification:') !!}

    <select name="qualification_id" class="form-control">
        @foreach($centre->qualification as $qualification)
            <option value="{{ $qualification->id  }}">{{ $qualification->title }}</option>
        @endforeach
    </select>

    <input type="text" name="purchase_order_number" id="purchase_order_number" value="{{ $purchase_order_number }}" />


    <hr/>
    @include ('errors.list')


    @include ('vault.form')

    {!! Form::close() !!}

@stop

Now when I store (create) a new candidate I have this controller function:

public function store(CandidateRequest $request)
{

    $candidateInput = Input::get('candidates');

    foreach ($candidateInput as $candidate)
    {
        $candidate = Candidate::create($candidate);

    }

    return redirect('candidates');
}

Is there any way to attach this $purchase_order_number to each candidate?

Many thanks.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1MR21Ew
via IFTTT

Aucun commentaire:

Enregistrer un commentaire