Level 63
With Livewire, you need a rule for each field in the form.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
am having issue with date and time when i want to create ads , if i remove start_at the form will submit succesfully if i add it back the form will not submit
am using pikaday cdn
<div>
<div class="px-6 py-6 mx-4 mt-4 text-left bg-white dark:bg-dark-eval-1 md:w-1/3 lg:w-1/3 sm:w-1/3">
<form wire:submit.prevent="create" class="w-full">
<div>
<label class="block" for="Name">Title<label>
<input wire:model='title' type="text" placeholder="Title"
class="w-full dark:bg-black px-4 py-2 mt-2 border rounded-md focus:outline-none focus:ring-1 focus:ring-blue-600">
</div>
<div class="mt-4">
<label class="block" for="email">Amount<label>
<input wire:model.defer='amount' type="text" placeholder="Amount"
class="w-full dark:bg-black px-4 py-2 mt-2 border rounded-md focus:outline-none focus:ring-1 focus:ring-blue-600">
</div>
<div class="mt-4">
<label class="block">Description<label>
<textarea wire:model.defer='body' type="text" placeholder="Ads Description"
class="w-full dark:bg-black px-4 py-2 mt-2 border rounded-md focus:outline-none focus:ring-1 focus:ring-blue-600"></textarea>
</div>
<div class="mt-4">
<select wire:model.defer="state" id="section" type="section" name="section" class="block w-full px-4 py-2 mt-2 text-gray-700 bg-white border border-gray-300 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-500 dark:focus:border-blue-500 focus:outline-none focus:ring">
<option value="">Select Location</option>
@foreach ($states as $state)
<option value="{{ $state->id }}">{{ $state->name }}</option>
@endforeach
</select>
</div>
<div class="form-control mt-4">
<label class="label block cursor-pointer">
<span class="upppercase">Start Now</span>
<input wire:model.defer='start_now' value="1" type="radio" name="radio-10" class="radio checked:bg-red-500"
checked />
</label>
</div>
<div x-data="{ show: false }">
<button type="button" @click="show = !show" :aria-expanded="show ? 'true' : 'false'" :class="{ 'active': show }">
Start Later
</button>
<div x-show="show">
<x-input.date placeholder="Choose Date" wire:model="start_at" :error="$errors->first('start_at') "/>
</div>
</div>
<div class="mt-4">
<button class="w-full px-6 py-3 mt-4 text-white bg-purple-600 rounded-lg hover:bg-blue-900">Create
Ads</button>
</div>
</form>
<div>
</div>
component
class Create extends Component
{
public $user_id;
public $title;
public $body;
public $state;
public $start_at;
public $ad_number;
public $amount;
public $start_now;
protected $rules = [
'state' => 'required|integer|exists:states,id',
'title' => 'required|min:4',
'body' => 'required|min:4',
];
public function create()
{
if (auth()->check()) {
$this->validate();
$number = rand(10000000, 99999999);
$ads = Ads::create([
'user_id' => auth()->user()->id,
'state_id' => $this->state,
'title' => $this->title,
'body' => $this->body,
'clone_ad' => 0,
'ad_number' => $number,
'amount' => $this->amount,
'start_at' => $this->start_at,
'start_now' => $this->start_now,
]);
$ads->setStatus('pending', 'needs verification');
}
}
public function render()
{
$states = State::latest()->get();
return view('livewire.ads.create', compact('states'));
}
console
Uncaught (in promise) Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received
Please or to participate in this conversation.