how to get data from input with custom page
i want get my data from input like this, with wire:model
and then i got error like this
my resource like this already to iniatialization
i just want to get data harga_awal and then calculate with harga_akhir then data will be show to custom page input
Solution:Jump to solution
```
<input class="w-15 text-xs h-8 dark:bg-zinc-800 dark:text-white rounded-md border shadow-sm border-zinc-200 dark:border-zinc-700"
type="number"
value="{{ $orderDetail->quantity }}"
wire:change="updateQuantity({{ $orderDetail->id }}, $event.target.value)"...
56 Replies
view my custom page
any ideas how to get data ?
You didn’t set any data for
harga_awals
. That’s what the error message tells you.
You should do this on mount()
already set my data like this but why after i change data from input not update database ?
already set my input and then not update
- Is
harga_awal
fillable?
- Did you verify whether updateQuantity()
is called?
- Did you verify the data that is sent?data harga_awal is fillable, then updateQuantity get data from quantity
or just create function for harga_awal to get value ? like this
my function for updateHargaAwal
It would help to read the view code, if you trim the space in front.
updateQuantity get data from quantityDid you verify that it is called? The quantity is updated?
updateHargaAwalIs this even called? You called it
harga_awalS
with an s
in the endmy quantity already updated but my harga_awals not update if im using wire:model
wait i will change
wire:change="updateHargaAwal({{ $orderDetail->id }}, $event.target.value)" />This feels a bit hacky. Livewire already sync to your properties through
wire:model
. You shouldn't need to pass the value again.Do
wire:model.blur="harga_awal"
and use Livewires lifecycle hook updatedHargaAwal
(https://livewire.laravel.com/docs/lifecycle-hooks#update`)Laravel
Lifecycle Hooks | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
but my data not insert to database if im using wire:model
wire:model
doesn't write to your DB. It binds it to Livewire.
You need to debug from there
But I can't help you, if you can't to some basic debuggingand how to insert, if im using this ?
$transaksiDetail
should be a property on the Page (or is this a table, then you still need the wire:change)
Then you can do:
This is all unrelated to Filament. It's pure Livewire at this pointand how to get my quantity value ? if im using before like this
Are you even changing harga_awals or do you just submit the default value?
value="{{ $orderDetail->harga_awal }}"
I don't think that will trigger an update.
Otherwise I guess your initial example should workjust submit from im input, i think no need to set value ?
I don't understand. Did you manually change the
harga_awals
input? So you entered a new valuei just input my data harga_awal then insert to database
but why im using this not inserted to database ?
I don't understand
Can you share a video of inputting the data and the data that you get just before calling update?
this my code resource
and this my blade code
i want to take value from blade with wire:model then im update to database. my question updateQuantity() im using your code because not save if using wire:change my input not update to database
Please share a short video as per my last message
just want update my quantity, then im calculate if database insert. just no need to look my value from blade
You missed that part:
Can you share a video of inputting the data and the data that you get just before calling update?Btw. when is
$recordDetail
set? I can't see in anywherefrom public TransaksiPembelianDetail $recordDetail
That's just an empty property? Where is it set?
And again: Did you debug (e.g. with a simple
dd()
) that your update methods are actually called and checked the data?
I can't help you if you don't debug the actual code and just show UI and Databasewhere im input debug ?
I don't know about your experience, but you should learn how to Debug in PHP and Laravel. This is essential so people can actually help you
inputting the data
What does this ouput?
As I said: You just show me UI and Database. This doesn't take us any further as we need to check on your code.
Also: You removed the
wire:change=""
now? So that method get's never called?yes if im using wire change like this, wait i will show you and record
For the Livewire hook to trigger immediately you need
wire:model.blur
this function will insert to database if submit ?
i mean this
No. It should dump the current data when the fuction is called?
Nothing happens? Then the method is never called
Step 1 for debugging: Check if your code actually runs!
this function means
if im using wire change will be update if im change my input
Please add that code do
updateQuantity()
I currently don't care about you Database.
Add the
dd()
code in therewhat you want to screenshot?
Wait.
updateQuantity()
does work right?yes because im using wire:change
Solution
Can you do
wire:model.blur="harga_awal"
for harga awal input and use updatedHargaAwal()
and see if this method is run (with dd)?not run with dd if im using like this
Can you try renaming it to
hargaAwal
?i think posible to create new function right ? like one by one harga_awal same with quantity ?
from debugbar but how to take this value then update ?
And
updatedHargaAwal()
is still not triggered?not triggered
if im duplicate this function then im change for updateHargaAwal, and my blade same with updateQuantity its work
Dude, it's still
updatedHargaAwal()
. d
in the end
So everything works with that solution? I thought that one wasn't working in the beginning?its same im change with hargaAwal() not trigger
you say this in the beginning ? (im so sorry sir if you say that), its work but i just want to simple like updateQuantity with harga will change together like that but if cant i think just change one by one
@Dennis Koch thanks for help me, sorry make you confuse to understand