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.

Adding a custom component isn't working with schema

See original GitHub issue

I’m having such a headache lol I’ve been trying to add a multiselect since 3 days and I tried literally everything from the docs. Nothing seems to work.

What I want

  • adding the @vueform/multiselect component to the schema, or even better: creating a component FormkitMultiselect which has @vueform/multiselect as a child component
  • adding a label to this component in the same style like all other inputs (native formkit text inputs etc.)
  • correct value handling

What already works

  • having the VueMultiselect rendered with my provided options

Problems

  • how to add a label when using a custom component?
  • how to handle the data? (v-model) for some reason all values are selected (see screenshot)

I tried everything from the docs… createInput etc., but nothing worked for me.

My Code

@vueform/multiselect is provided globally via Nuxt plugin

import VueMultiselect from '@vueform/multiselect'

export default defineNuxtPlugin((nuxtApp) => {
    nuxtApp.vueApp.component("VueMultiselect", VueMultiselect)
})
const schema = ref<FormKitSchemaCondition | FormKitSchemaNode[]>([
    {
        $formkit: 'text',
        name: 'title',
        label: 'Recipe Title',
        validation: 'required',
        value: ''
    },
    {
        $cmp: 'VueMultiselect',
        props: {
            options: useRecipeBadges()
        }
    },
])

Passing schema to a wrapper component


<FormBuilder
    :schema="schema"
/>

wrapper passes it to FormKit

<FormKit type="form" @submit="handleSubmit" :submit-label="submitLabel">
    <FormKitSchema
        :schema="schema"
    />
</FormKit>

All values selected Bildschirmfoto 2022-10-28 um 15 13 48

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
justin-schroedercommented, Oct 31, 2022

Thank you for the reproduction. I saw a number of issues that needed resolving, but rather than list them all out, here’s your reproduction working: https://stackblitz.com/edit/vueform-multiselect-formkit

Best of luck 👍 And if you enjoy FormKit, consider using our Pro inputs next time to help support the project 🙂

0reactions
phillipmohrcommented, Oct 31, 2022

@justin-schroeder thanks for your time!

Read more comments on GitHub >

github_iconTop Results From Across the Web

CUSTOM_ELEMENTS_SCHEMA added to NgModule ...
This worked for me on TestBed . Element was working fine but test was failing. Added schemas: [NO_ERRORS_SCHEMA] , and it's all good....
Read more >
Angular 10 Custom Elements not found · Issue #39115 - GitHub
I used CUSTOM_ELEMENTS_SCHEMA but Custom Element not found ... add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to ...
Read more >
You're using CUSTOM_ELEMENTS_SCHEMA wrong.
If you're using Angular together with Web Components, you need to add CUSTOM_ELEMENTS_SCHEMA to your module import, like this:.
Read more >
Custom component: is not a known element: - Ionic Framework
I have generate a new ionic component with command: ionic g ... then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this ...
Read more >
Custom components | Decentraland Documentation
You may want to add a component that simply flags an entity to differentiate it from others, without using it to store any...
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