How to pass data from view to Resource TextInput?
Guys, need help! I have Resource with $form where custom view renders svg image with different clickable areas, I need to pass clicked svg path id from that view to $form TextInput, how can I do that?
Solution:Jump to solution
another reference: https://livewire.laravel.com/docs/javascript#using-javascript-in-livewire-components
Laravel
JavaScript | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
17 Replies
What code are you doing?
In filament.map.svg i've a svg map, when I click on certain area I get an id of the area in console, but I can't figured out how to pass the id to the TextInput::make('obj_id')
would you like to set a value?
yes
hum.. maybe
$wire.$set('data.obj_id', 'new_value')
?I didn't create Livewire component just view for svg, should I create it for that?
could you share the code you are using in this view?
here it is - https://codepen.io/steamn/pen/BaeadXM
Did you try my code? Any console errors?
Sorry, but I don't know how to use it(
on click?
$wire is not defined in console
I think you can use something like this
my svg file is too big and complex (it's map overlay), so I can't follow your suggestion.
Is it possible to use $wire.$set inside JS script like on that screenshot?
I think so, but I think you should use alpineJs
https://alpinejs.dev/
Alpine.js
A rugged, minimal framework for composing behavior directly in your markup.
Solution
another reference: https://livewire.laravel.com/docs/javascript#using-javascript-in-livewire-components
Laravel
JavaScript | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
Wrapping the script with @script @endscript solved the issue!
thank you so much Leandro!