Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #229
    jacob_smith
    Participant

    Hi, I have the following livewire components:

    Class:

    <?php

    namespace App\Http\Livewire;

    use Livewire\Component;

    class Message extends Component
    {

    public $message = false;

    public function render()
    {
    return view(‘livewire.message’);
    }
    }

    View:

    <div>
    <input type=”checkbox” wire:model=”message” >
    </div>

    {{var_export($message)}}

    When the view component is loaded the false value is shown in display but when I click on the checkbox the true value won’t be shown. What should happen is that false display will be replaced with true.

    • This topic was modified 1 year, 4 months ago by jacob_smith.
    #231

    The problem is in the view component of livewire. Always remember that there should only be one wrapping div in the view component of livewire. You have to move {{var_export($message)}} inside the div like this:

    <div>
    <input type=”checkbox” wire:model=”message” >
    {{var_export($message)}}
    </div>

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.