sagalbot / vue-select

Everything you wish the HTML <select> element could do, wrapped up into a lightweight, extensible Vue component.
https://vue-select.org
MIT License
4.62k stars 1.33k forks source link

Add Input "name" prop for using in forms #1684

Closed lisunovdv closed 1 year ago

lisunovdv commented 1 year ago

It will be very nice to have the ability to set HTML <input name="" attribute for easy form serializing:

<script setup>
const form = ref(null);
</scipt>
<form ref="form" method="POST" action="/add-user.php">
        <VueSelect :name="user_name_qx4fhrkkd" ...>
        <button
               type="submit"
               @submit="fetch(
                         '/add-user.php',
                        {
                             method: 'post',
                             body: new FormData(form),
                         },
)"></button>

Currently, we are using:

<VueSelect :value="val"></VueSelect>
<input type="hidden" name="user_name_qx4fhrkkd" value="val" />
sagalbot commented 1 year ago

That's currently the recommended method for setting the name prop.