Inertia: v-model for file input type

Created on 4 Apr 2021  路  7Comments  路  Source: inertiajs/inertia

Versions:

  • @inertiajs/inertia version: ^0.8.6
  • @inertiajs/inertia-vue3 version: ^0.3.10

Describe the problem:

How does v-model should work in an example if we can't use it with file input type?
VueJS will throw the error "v-model cannot be used on file inputs since they are read-only."
This should be updated in documentation. We need to use @change for file input.

Most helpful comment

Updated: https://github.com/inertiajs/inertiajs.com/commit/73f6e1a16e502405c4c5d93db4eee73da47e29d0

In the future, please post documentation related issues in that repo. 馃憤

All 7 comments

I exactly come through to it. Can you elaborate @RomkaLTU the solution ?

VueCompilerError: v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.

@bedus-creation

<input type="file" @input="form.avatar = $event.target.files[0]" />

This isn't really something Inertia needs to document, as this is known Vue behaviour, and isn't specific to Inertia.

Well, I disagree, there is a mistake in the documentation and that should be corrected imho. It's not about full implementation but you can't do v-model on file input type.

Oh I'm sorry, where is this wrong in the docs?

Feel free to create an issue in the documentation repo, or even better, submit a PR to fix this. 馃憤

Updated: https://github.com/inertiajs/inertiajs.com/commit/73f6e1a16e502405c4c5d93db4eee73da47e29d0

In the future, please post documentation related issues in that repo. 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sebastiandedeyne picture sebastiandedeyne  路  6Comments

mpskovvang picture mpskovvang  路  5Comments

piercemcgeough picture piercemcgeough  路  4Comments

ambethia picture ambethia  路  5Comments

gajosadrian picture gajosadrian  路  5Comments