I have a select element in cart.blade file like this:
<select wire:model="category">
@foreach ($categories as $item)
<option value="{{$item->id}}">{{$item->name}}</option>
@endforeach
</select>
and when I selected an item from the list, it will not send the value of the option tag to the category variable in the component (just sends the sorted numbers of selected options starts from 1 to n).
how to send the value of an option tag to wire:model=" category"?
Would you mind trying the following?
class GroupMoney extends Component
{
public $category_id;
public $category;
public function updatedcategory($value)
{
if (!empty($value)) {
$this->category_id = category::find($value);
}
}
}