0

I need to create a new array inside a blade and then post it within a request, but it just keeps spitting out the id's as key value pairs.

I need a named array that I can specifically target and iterate through... any suggestion??

@foreach ($allTheAgreements as $agreement)
    <tr>
        <td><input type="checkbox" name="{{$agreementID[] = $agreement->id}}" id="{{ $agreement->id }}" 
        value="{{ $agreement->id }}">
        </td>
        <td>{{ $agreement->id }}</td>
        <td>{{ $agreement->agreement_type }}</td>
        <td>Agreement Status</td>
    </tr>
@endforeach

enter image description here

So how do I initialise a new array within a blade template input element and get the indexed values back?

Something like

$arrayWithinRequest[] = [ 0 => '2', 1 => '5', 2 => '7'};
2
  • 2
    Try <input type="checkbox" name="agreements[{{$agreement->id}}]" id="{{ $agreement->id }}" value="{{ $agreement->id }}"> Commented Mar 2, 2022 at 11:43
  • That's done it, so simple, so eligant haha, thank you my friend Commented Mar 2, 2022 at 11:47

1 Answer 1

1

Try

<input type="checkbox" name="agreements[{{$agreement->id}}]" id="{{ $agreement->id }}" value="{{ $agreement->id }}">
Sign up to request clarification or add additional context in comments.

Comments

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.