WallyJ
1 month ago
249
2
Laravel

Property [taskduedate] does not exist on the Component instance.

Posted 1 month ago by WallyJ

I thought I followed the docs for this Livewire component but I am receiving this error:

Livewire controller:

<?php

namespace App\Http\Livewire;

use Livewire\Component;
use App\Task;

class Contactshow extends Component
{

    public $contacts;
    public $tasktext;
    public $deal_id = '';

    public function mount($contacts)
    {
        $this->contacts = $contacts->toArray();
    }

    public function render()
    {
        return view('livewire.contactshow');
    }

    public function addTask()
    {
        Task::create([
            'deal_id' => $this->deal_id,
            'tasktext' => $this->tasktext,
            'taskduedate' => $this->taskduedate,

        ]);
    }
}

View Code:

<div class="form-row">
        <div class="input-group date form-group col-md-9">
               <input type="text" name="tasktext" class="form-control" id="tasktext" placeholder="New Task" wire:model="tasktext">
        </div>
        <div class="form-group col-md-3" id="datepickerfield">
                 <div class="input-group date">
                     <input type="text" name="taskduedate" class="form-control" id="taskduedate" placeholder="Due Date" wire:model="taskduedate" data-provide="datepicker" data-date-autoclose="true" data-date-today-highlight="true" autocomplete="off">
                 </div>
        </div>
</div>
<div class="form-row">
        <div class="form-group col-md-12">
                <input type="hidden" name="deal_id" value="{{ $deal['id'] }}" wire:model="deal_id">
                <button class="btn btn-primary" wire:click="addTask" type="submit">Add</button>
         </div>
</div>

Not sure why it isn't catching 'deal_id' since I used 'wire:model="deal_id"'.

Wire:model should work on hidden fields, right?

Please sign in or create an account to participate in this conversation.