Skip to content

Commit

Permalink
fix(components): form v2 bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuagraber committed Oct 9, 2024
1 parent c362b2e commit bafdd38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/components/FormV2/PdapFormV2.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<template>
<form :id="id" :name="name" class="pdap-form" @submit.prevent="submit">
<form
:id="id"
:name="name"
class="pdap-form"
@submit.prevent="submit"
@change="emit('change', values, $event)"
>
<slot v-if="$slots.error" name="error" />
<div
v-else-if="typeof errorMessage === 'string'"
Expand Down Expand Up @@ -29,12 +35,12 @@ const { defaultValues, error, schema } = withDefaults(
);
// Emits
const emit = defineEmits(['submit']);
const emit = defineEmits(['submit', 'change']);
// Constants
const errorMessage = ref(error);
const values = ref(defaultValues ?? {});
const rules = makeRules(schema);
const rules = schema ? makeRules(schema) : {};
const v$ = useVuelidate(rules, values, { $autoDirty: false, $lazy: true });
// Provide
Expand Down
1 change: 1 addition & 0 deletions src/demo/pages/FormV2Demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
name="form-name"
:schema="SCHEMA"
@submit="(values) => console.log({ values })"
@change="(values, event) => console.log({ values, event })"
>
<InputText
:id="INPUT_TEXT_NAME"
Expand Down

0 comments on commit bafdd38

Please # to comment.