Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit a557fd0

Browse files
authored
Merge pull request #212 from asigloo/bugfix/form-options
Bugfix/form options
2 parents 1cce47d + 0cbc9c5 commit a557fd0

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

dev/typescript/App.vue

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<div class="relative card p-6 bg-white">
1010
<h1 class="title mb-16 text-bg">{{ title }}</h1>
1111
<dynamic-form
12+
class="awiwi"
1213
:form="form"
1314
@submitted="handleSubmit"
1415
@change="valueChanged"
@@ -245,6 +246,9 @@ export default defineComponent({
245246
readonly: true,
246247
}),
247248
},
249+
options: {
250+
customClass: 'mandalorian',
251+
},
248252
}));
249253
250254
function handleSubmit(values) {

src/components/dynamic-form/DynamicForm.vue

+7-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ const components = {
8282
*/
8383
export default defineComponent({
8484
name: 'asDynamicForm',
85-
inheritAttrs: false,
8685
props,
8786
components,
8887
setup(props, ctx) {
@@ -141,15 +140,20 @@ export default defineComponent({
141140
});
142141
143142
const formattedOptions = computed(() => {
144-
if (options?.form) {
143+
let opts = {
144+
...options?.form,
145+
...props.form?.options,
146+
};
147+
148+
if (opts) {
145149
const {
146150
customClass,
147151
customStyles,
148152
method,
149153
netlify,
150154
netlifyHoneypot,
151155
autocomplete,
152-
} = options?.form;
156+
} = opts;
153157
return {
154158
class: customClass,
155159
style: customStyles,

src/core/models.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface DynamicForm {
2626
id: string;
2727
fields: FormFields;
2828
fieldOrder?: string[];
29+
options?: FormOptions;
2930
}
3031

3132
export interface ErrorMessage {
@@ -151,8 +152,8 @@ export type FormControl<T extends InputType> = T & {
151152
};
152153

153154
export interface FormOptions {
154-
customClass?: string | string[] | BindingObject | BindingObject[];
155-
customStyles?: string | string[] | BindingObject | BindingObject[];
155+
customClass?: string | string[] | BindingObject | BindingObject[] | unknown;
156+
customStyles?: string | string[] | BindingObject | BindingObject[] | unknown;
156157
method?: string;
157158
netlify?: boolean;
158159
netlifyHoneypot?: string;

0 commit comments

Comments
 (0)