Last active
April 8, 2022 02:18
-
-
Save tonysm/343a0de2a3c1de36c306905778f5957c to your computer and use it in GitHub Desktop.
Combining Turbo Frames and Streams
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<x-app-layout title="New Invitations"> | |
<h1>New Invitations!</h1> | |
<form action="{{ route('invitations.store') }}" method="POST"> | |
<div id="invitations"></div> | |
<button type="submit">Invite</button> | |
</form> | |
<x-turbo-frame id="create_trigger_invitations"> | |
<x-turbo-stream target="invitations" action="append"> | |
@php $invitationIndex = request('invitation', 0); @endphp | |
<div> | |
<div> | |
<label for="invitations_{{ $invitationIndex }}_name">Name</label> | |
<input type="text" name="invitations[{{ $invitationIndex }}][name]" placeholder="Jane Doe" id="invitations_{{ $invitationIndex }}_name" /> | |
</div> | |
<div> | |
<label for="invitations_{{ $invitationIndex }}_email">Email</label> | |
<input type="email" name="invitations[{{ $invitationIndex }}][email]" placeholder="[email protected]" id="invitations_{{ $invitationIndex }}_email" /> | |
</div> | |
<br /> | |
</div> | |
</x-turbo-stream> | |
<a href="{{ route('invitations.create', ['invitation' => ++$invitationIndex]) }}">Add More</a> | |
</x-turbo-frame> | |
</x-app-layout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment