Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use mapMultiRowFields on nested state ? #50

Closed
blackinitial opened this issue Feb 18, 2019 · 3 comments
Closed

how to use mapMultiRowFields on nested state ? #50

blackinitial opened this issue Feb 18, 2019 · 3 comments
Assignees
Labels

Comments

@blackinitial
Copy link

blackinitial commented Feb 18, 2019

i use nuxt js, i want to implementation dynamic form like https://markus.oberlehner.net/blog/how-to-handle-multi-row-forms-with-vue-vuex-and-vuex-map-fields/
how to access mapMultiRowFields on nested state store, bookingData.flight.passengers ?
and i got error store.getters[getterType] is not a function

store/bookingData.js

import { getField, updateField } from 'vuex-map-fields'

export const state = () => ({
  flight: {
    contact: {
      title: '',
      fullname: '',
      email: '',
      phone: ''
    },

    passengers: [
      {
        title: '',
        fullname: '',
        birthday: ''
      },
      ...
    ]
  }
})

export const getters = { getField }

export const mutations = {
  updateField
}

component.vue

<template>
.card.shadow.mb-4(v-for="passenger, index in passengers" v-on:key="'passengers'+index")
  input.form-control(
    type="text" required
    v-model="passenger.fullname")
.....

<script>
.....
computed: {
  ...mapMultiRowFields({ passengers: 'bookingData.flight.passengers' })
}
.....
@maoberlehner
Copy link
Owner

Hey @blackinitial!

Am I right that bookingData is a namespaced module? If so, this should help: https://codesandbox.io/s/2v042zjw0r

You can read more about dealing with namespaced modules here: https://github.com/maoberlehner/vuex-map-fields#namespaced-vuex-modules

@maoberlehner maoberlehner self-assigned this Feb 25, 2019
@geoidesic
Copy link
Collaborator

Closing this due to no further feedback from OP.

@lasteuropean
Copy link

Hey @blackinitial!

Am I right that bookingData is a namespaced module? If so, this should help: https://codesandbox.io/s/2v042zjw0r

You can read more about dealing with namespaced modules here: https://github.com/maoberlehner/vuex-map-fields#namespaced-vuex-modules

I'm struggling with this exact issue; the difference is that I'm using Nuxt.js and am having trouble implementing this part:

const store = new Vuex.Store({ // ... modules: { bookingData } });

Any advice? Also get this message in my developer console when I use mapMultiRowFields
"(error during evaluation)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants