Home > Software design >  input form file twig symfony
input form file twig symfony

Time:02-04

i have a little problem, i would like use beautiful form for my drop file panel, but in twig i try to pass information, i know attr class but for other i don't know

        <input accept="*" type="file" multiple  id="announces_images" @change="addFiles($event)" @dragover="$refs.dnd.classList.add('border-blue-400'); $refs.dnd.classList.add('ring-4'); $refs.dnd.classList.add('ring-inset');" @dragleave="$refs.dnd.classList.remove('border-blue-400'); $refs.dnd.classList.remove('ring-4'); $refs.dnd.classList.remove('ring-inset');" @drop="$refs.dnd.classList.remove('border-blue-400'); $refs.dnd.classList.remove('ring-4'); $refs.dnd.classList.remove('ring-inset');" title=""/>
    

i try to convert with twig

    {{ form_row(form.images,{'attr': {'class':'absolute inset-0 z-50 w-full h-full p-0 m-0 outline-none opacity-0 cursor-pointer', '@change':'addFiles($event)'}}) }}

it's good for @change??? someone help me, thank u!!

CodePudding user response:

What I prefer to do is add a class in my form type. It prevent me the day when my variables "images" change to not impact the js.

"js-images-on-change" for example.

and in my javascript

$('.js-images-on-change').on('change', function() {
  addFiles($(this))
}
  • Related