Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing boolean value in $set magic action in livewire

I am new in laravel livewire. I am trying to toggle a modal using livewire. For that I have taken a variable name $isOpenModal. Initially it is false. When I click a radio input the value of $isOpenModal turn to true using $set('isOpenModal','true'). It opens the modal succesfully. When I click the close button I tried to close the modal using $set('isOpenModal','false'). But this is not working.

Here is my code

<div class="w-2/5 p-1 text-center "  wire:click="$set('isOpenModal', 'true')">
     <label class="labl">
         <input type="radio" name="radioname" value="one_value"/>
         <div class="rounded-lg py-2 px-3">{{trans('strings.change')}}</div>
     </label>
</div>



<div class="d-flex justify-content-center align-items-center" >
    <button wire:click="$set('isOpenModal', 'false')">
        <div class="btn btn-danger">
            <span class="text-base text-white-400 hover:text-white-300">{{trans('strings.close')}}</span>
        </div>
     </button>
</div>

How do I pass false value in the $set method. I have tried passing 0 and It's works . But I need to work with boolean

like image 277
Md. Azahar Alam Avatar asked Sep 09 '25 14:09

Md. Azahar Alam


1 Answers

you are passing 'true' / 'false' as string. pass it without ' '.

like this

wire:click="$set('isOpenModal', true)"

Hope it helps. let me know

like image 154
fahim152 Avatar answered Sep 12 '25 02:09

fahim152