live input problem after submit ( laravel / livewire )

hello
36 Replies
NIMA
NIMAOP2w ago
im using livewire and testing a simple crud app but when im adding my components (input) to a modal after updating or adding a new user input wont get refresh but the value of the model will be empty but input will still have the value and not refresh it im even use resset function and still not work $this->reset(['name', 'lastname', 'number']); anyone know the problem ? here is my code this my blade file i read all the document and ask some people + ais but i got no answers i also clear the cache but it wont works
ἔρως
ἔρως2w ago
can you reduce the code to 5% it's size and still reproduce the issue?
NIMA
NIMAOP2w ago
what u mean ?
ἔρως
ἔρως2w ago
because nobody is going to read almost 16kb of that horrible language to help you plus the code you have outside
NIMA
NIMAOP2w ago
oh mb 🤣
ἔρως
ἔρως2w ago
thats why you dont get any answers thats still way too big
NIMA
NIMAOP2w ago
i think i need to send it in multy parts discord dont let me send all az a text
ἔρως
ἔρως2w ago
thats because it is still way too much
NIMA
NIMAOP2w ago
this is 1 of my inputs im using in my blade file rn and also
ἔρως
ἔρως2w ago
no no no can you grab your code, and shave it as much as possible, until what is left cant be reduced any further while still showing the problem? i see you have an x-crude.input component
NIMA
NIMAOP2w ago
like this ?
ἔρως
ἔρως2w ago
is it really required? or can you reproduce it with a normal input? if i grab that code, can i reproduce the error?
NIMA
NIMAOP2w ago
nop
ἔρως
ἔρως2w ago
then it isnt a minimal reproducible example
NIMA
NIMAOP2w ago
im trying to dont send the thing its not necesery but they are so many 😅
ἔρως
ἔρως2w ago
Stack Overflow
How to create a Minimal, Reproducible Example - Help Center
Stack Overflow | The World’s Largest Online Community for Developers
ἔρως
ἔρως2w ago
read that seriously, read this
NIMA
NIMAOP2w ago
i will make one from scratch
ἔρως
ἔρως2w ago
yes, start from scratch and try to cause the problem just add the minimum to cause the problem if the problem happens, remove stuff until it doesnt cause the problem add back what you removed and see if the problem happens keep at it until adding or removing some small portion causes or fixes the issue
NIMA
NIMAOP2w ago
<?php
use App\Models\name;
use Livewire\Attributes\Layout;
use Livewire\Volt\Component;
new #[Layout('layouts.wellcome')] class extends Component {


public $name = '' ;

protected $rules = [
'name' => ['required', 'string', 'max:255'],

];

public function add()
{
$this->validate();
$this->cancel();

}

public function cancel(): void
{

$this->reset(['name']);
}
}; ?>


<div>
<form wire:submit.prevent="add" class="mt-5 justify-center items-center">
<div class="mb-8 mx-1">
<input wire:model="name" id="name" type="text" name="name">
@error('name')<p class="text-red-500 text-sm mt-2">{{ $message }}</p>@enderror
</div>
<button wire:loading.attr="hidden" type="submit" class="mt-2 mx-1 border px-5 py-2 text-blue-700 rounded-lg border-gray-500">Create</button>
</form>
</div>
<?php
use App\Models\name;
use Livewire\Attributes\Layout;
use Livewire\Volt\Component;
new #[Layout('layouts.wellcome')] class extends Component {


public $name = '' ;

protected $rules = [
'name' => ['required', 'string', 'max:255'],

];

public function add()
{
$this->validate();
$this->cancel();

}

public function cancel(): void
{

$this->reset(['name']);
}
}; ?>


<div>
<form wire:submit.prevent="add" class="mt-5 justify-center items-center">
<div class="mb-8 mx-1">
<input wire:model="name" id="name" type="text" name="name">
@error('name')<p class="text-red-500 text-sm mt-2">{{ $message }}</p>@enderror
</div>
<button wire:loading.attr="hidden" type="submit" class="mt-2 mx-1 border px-5 py-2 text-blue-700 rounded-lg border-gray-500">Create</button>
</form>
</div>
ok i got a public named $name and its empty and i have a form it have input with wire model name az name so it will get the item from input and send it to the $name but there is a problem after i submit it public $name will be empty but input still have the value and even i try to submit it it say the input its empty but still there is value on it
NIMA
NIMAOP2w ago
example
No description
ἔρως
ἔρως2w ago
does it happen if you use an actual input?
NIMA
NIMAOP2w ago
yes real input have same problem even if i dont use components
ἔρως
ἔρως2w ago
right now, you are still using that misterious x-crid.input field
NIMA
NIMAOP2w ago
i fix it but it still have the same problem i use similer method like this 3 day ago and it was working fine i dont know why this happen now
ἔρως
ἔρως2w ago
your input doesnt have a name
NIMA
NIMAOP2w ago
but im using wire model even i use the name="name" it still wont refrsh the input
ἔρως
ἔρως2w ago
you're right wire:model should take care of it
NIMA
NIMAOP2w ago
ye
ἔρως
ἔρως2w ago
can you remove the name and id and try again?
NIMA
NIMAOP2w ago
ye it still got same issue and even try to add a value with $name but still no work
ἔρως
ἔρως2w ago
you validate and cancel imediately after
NIMA
NIMAOP2w ago
ye cuse i make the code shorter in middel of them it will create a row in data base and add name + last name + number in the orginal code have problem too . the problem is i dont know why the content of the input wont get resset after submiting and input still have a value like place holder but in public $name there is no value and its empty i fix the problem <script src="//unpkg.com/alpinejs" defer></script> this script was in my layot file 🤣 🤣 🤣 the code was working fine only this script block it some how
ἔρως
ἔρως2w ago
that does seem to have the potential to interfeer with the code that explains why the code looked fine to me: because it was
NIMA
NIMAOP2w ago
ye code was working fine after i add some component i add this script by mistake
ἔρως
ἔρως2w ago
thats fine it happens but reducing did help to see that the code is fine

Did you find this page helpful?