Skip to content

Instantly share code, notes, and snippets.

@LazyFatArrow
Last active May 29, 2019 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LazyFatArrow/c1122bb0531f0efa0b5780cc15497899 to your computer and use it in GitHub Desktop.
Save LazyFatArrow/c1122bb0531f0efa0b5780cc15497899 to your computer and use it in GitHub Desktop.
<template>
<div>
<b-button @click="isModalVisible = true">Create Poll</b-button>
<b-modal
v-model="isModalVisible"
@ok="$emit('createPoll', pollForm)"
title="Create a new poll"
centered
>
<b-form-group label="Title">
<b-form-input
v-model="pollForm.title"
/>
</b-form-group>
<b-form-group label="Description">
<b-form-textarea
v-model="pollForm.description"
/>
</b-form-group>
<b-form-group label="Options">
<b-form-input
v-model="pollForm.options[index].name"
v-for="(option, index) in pollForm.options"
:key="`poll-form-option-${index}`"
/>
</b-form-group>
<b-form-group>
<b-btn @click="addOption">Add Option</b-btn>
</b-form-group>
</b-modal>
</div>
</template>
<script>
export default {
methods: {
addOption() {
this.pollForm.options.push({
name: '',
})
},
},
data: () => ({
isModalVisible: false,
pollForm: {
title: '',
description: '',
options: [
{
name: '',
}
],
},
})
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment