I think the livewire is much easier than Alpine js ( Actually, I Did not work on it and have much experience on Livewire )
You should try using Livewire
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am very new to Alpine JS.
I need to create a form where the user can click on a button that will create form fields.
e.g. when the user clicks the button it will add these fields to the form:
Select field: (with data from bags table) Empty Input field for Price Empty Input field for Stock
so the user will be able to add as many of these as he wants.
I found this code example:
https://codepen.io/sanjayojha/pen/qBONdVm
but this example only creates empty fields, and I don't know if it's possible to create the dropdown using data from a model coming from Livewire component?
I tried to find a tutorial or example but could not find anything.
Yes you can. You can access Livewire component properties using $wire. I created that jsFiddle as an example. I created $wire manually, but that should be available in your Livewire component.
However, you can create an array on the Livewire component and a method to add an element to add, that way you will the array isn't going to created on the server and you will need an request for add or removing an element. That shouldn't be a problem if you have small app.
Please or to participate in this conversation.