question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to add more data to the form dynamically

See original GitHub issue

I was wondering if it’s possible to add more data to the form after it’s been instantiated?

For example (psuedo code):

<template>
    <select v-model="form.approvers" multiple id="approvers" name="approvers"></select>
</template>

<script>
export default {
    data() {
        return {
            form: new Form({
                approvers: [],
            })
        }
    }

    mounted() {
         $('#approvers').select2({
            placeholder: "Enter approvers ",
        });
    },

    methods: {
        save() {
            // Ex.
            this.form.setData(key, value);

            this.form.post();
        }
    }
}
</script>

I have a multi-select form input that is constructed using Select2, but using v-model="form.approvers" on the select doesn’t seem to post the selected values from select2.

Do you know of any ways around this or why it might not be grabbing the values from the select input?

Thanks! 😃

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
cretueusebiucommented, Jul 6, 2017

You can:

this.form.my_key = 'value'

But for your case you should make a custom component then have something like:

<select2 v-model="form.my_key"></select2>

https://vuejs.org/v2/examples/select2.html

Or try this one https://github.com/monterail/vue-multiselect

0reactions
arrcoronacommented, Apr 10, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamically creating a specific number of input form elements
Create new elements by means of document.createElement() , and use appendChild() to append each of them to the container. You might be interested...
Read more >
Able to add more fields dynamically within the form - Jotform
Hello, we're launching a campaign to update our database with the correct safety contacts within our member companies.
Read more >
Power Apps Dynamic Form Schema | Add Controls on the fly
In this video, you will learn how to build Dynamic Forms in Power Apps. We will create the controls of the Form dynamically...
Read more >
How to Create a Form Dynamically with the JavaScript?
Approach 1: Use document.createElement() to create the new elements and use setAttribute() method to set the attributes of elements. Append ...
Read more >
Dynamically add fields from a table into a form
If you want to add fields from your data source into a Edit form dynamically, I afraid that there is no way to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found