Formkit undefined _withMods in simple form

The application errored with 500 Cannot read properties of undefined (reading '_withMods') I assume this is cause bc following component:
<template>
<FormKit
type="form"
id="registrationForm"
@submit="handleSubmit"
:actions="false" >
<FormKit
type="text"
name="name"
label="Name"
validation="required"
validation-label="Name"
placeholder="Enter your name"/>

<FormKit
type="email"
name="email"
label="Email"
validation="required|email"
validation-label="Email"
placeholder="Enter your email"
/>

<FormKit
type="password"
name="password"
label="Password"
validation="required|length:8"
:validation-messages="{
length: 'Password must be at least 8 characters long'
}"
validation-label="Password"
placeholder="Create your password"
/>

<FormKit
type="password"
name="confirmPassword"
label="Confirm Password"
validation="required|confirm"
validation-label="Password Confirmation"
placeholder="Confirm your password"
:validation-rules="{ confirm: confirmPassword }"
:validation-messages="{
confirm: 'Passwords do not match'
}"
/>

<FormKit
type="text"
name="code"
label="Verification Code"
validation="required"
validation-label="Code"
placeholder="Enter verification code"
/>
<FormKit
type="submit"
label="Register"
input-class="submit-button"
/>
</FormKit>
</template>

<script setup>
const confirmPassword = (node) => {
return node.value === node.at('..').value?.password
}

const handleSubmit = async (formData) => {
try {
console.log('Registration submitted:', formData)
// Add your registration logic here
} catch (error) {
console.error('Registration error:', error)
}
}
</script>

<template>
<FormKit
type="form"
id="registrationForm"
@submit="handleSubmit"
:actions="false" >
<FormKit
type="text"
name="name"
label="Name"
validation="required"
validation-label="Name"
placeholder="Enter your name"/>

<FormKit
type="email"
name="email"
label="Email"
validation="required|email"
validation-label="Email"
placeholder="Enter your email"
/>

<FormKit
type="password"
name="password"
label="Password"
validation="required|length:8"
:validation-messages="{
length: 'Password must be at least 8 characters long'
}"
validation-label="Password"
placeholder="Create your password"
/>

<FormKit
type="password"
name="confirmPassword"
label="Confirm Password"
validation="required|confirm"
validation-label="Password Confirmation"
placeholder="Confirm your password"
:validation-rules="{ confirm: confirmPassword }"
:validation-messages="{
confirm: 'Passwords do not match'
}"
/>

<FormKit
type="text"
name="code"
label="Verification Code"
validation="required"
validation-label="Code"
placeholder="Enter verification code"
/>
<FormKit
type="submit"
label="Register"
input-class="submit-button"
/>
</FormKit>
</template>

<script setup>
const confirmPassword = (node) => {
return node.value === node.at('..').value?.password
}

const handleSubmit = async (formData) => {
try {
console.log('Registration submitted:', formData)
// Add your registration logic here
} catch (error) {
console.error('Registration error:', error)
}
}
</script>

I dont know what the error is
2 Replies
kapa.ai
kapa.ai4w ago
Hi @IsaacR943. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I apologize, but I'm not able to provide a specific answer to your question about FormKit based on the knowledge sources provided. The information given is focused on Nuxt and does not contain details about FormKit or the specific error you're encountering. However, I can offer some general advice: 1. The error "Cannot read properties of undefined (reading '_withMods')" suggests that something is trying to access a property '_withMods' on an undefined object. This could be related to how FormKit is set up or used in your Nuxt application. 2. Make sure you have properly installed and configured FormKit in your Nuxt project. This might involve checking your nuxt.config.js file and ensuring any necessary plugins are correctly set up. 3. Verify that you're using the correct version of FormKit that's compatible with your Nuxt version. 4. Double-check that all the imports related to FormKit are correct in your component. 5. If you're using any custom plugins or configurations with FormKit, ensure they're properly implemented. For more specific help with this FormKit issue in Nuxt, I recommend: 1. Checking the official Nuxt documentation for any information on integrating form libraries. 2. Consulting the FormKit documentation or community forums for similar issues. 3. If the problem persists, consider creating a minimal reproduction of the issue and seeking help on the Nuxt GitHub issues page or in the Nuxt community forums. Remember to provide details about your Nuxt version, FormKit version, and any relevant configuration when seeking help. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4w ago
<@1223715160502571129> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?