Please help me to get hidden input data when form submitting using livewire…i get null value while sending hidden input
Form query regarding hidden field
posting some code will help you get some answers
How are you setting the value of the hidden field? Are you changing it in javascript? If so, you’ll have to trigger an input event on the field to tell livewire to communicate the changes to your backend.
I send data from livewire component and using foreach loop display with view part and grasping the value and using form hidden field i put the value in value field while submiting form its display null
Uploading: 15919554824402807973501418620674.jpg…
Please see these code from there i send data to view
How to send hidden input field data in livewire? Bez when i sending hidden input using form its show null
I am also facing the same issue
This can be done using a little javascript
Example you have a select dropdown or an input that when specific event happens send to livewire the updated data.
Example
in backend i want to update the public property call hiddenvalue
<div wire:ignore>
<select id="data">
<option value="a"></optiion>
<option value="b"></optiion>
</select>
<input type="hidden" value="data" id="selectdata"/>
</div>
Javascript Part
@push('scripts')
document.getElementById('data').addEventListener('change', (event) => {
const result = document.getElementById("selectdata"); //Get the hidden field value
if (event.target.value=='a') //Just an example
{
@this.set('hiddenvalue',result.value); ///In this part you set property value base on hiddenfield in
backend
}
//This just an example on how you can send hidden fields to livewires., you can have other event listener or logic base on your needs.
});
@endpush
Any question let me know
Slick! man thanks for posting.