Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dev/typescript/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<div class="relative card p-6 bg-white">
<h1 class="title mb-16 text-bg">{{ title }}</h1>
<dynamic-form
class="awiwi"
:form="form"
@submitted="handleSubmit"
@change="valueChanged"
Expand Down Expand Up @@ -245,6 +246,9 @@ export default defineComponent({
readonly: true,
}),
},
options: {
customClass: 'mandalorian',
},
}));

function handleSubmit(values) {
Expand Down
10 changes: 7 additions & 3 deletions src/components/dynamic-form/DynamicForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ const components = {
*/
export default defineComponent({
name: 'asDynamicForm',
inheritAttrs: false,
props,
components,
setup(props, ctx) {
Expand Down Expand Up @@ -141,15 +140,20 @@ export default defineComponent({
});

const formattedOptions = computed(() => {
if (options?.form) {
let opts = {
...options?.form,
...props.form?.options,
};

if (opts) {
const {
customClass,
customStyles,
method,
netlify,
netlifyHoneypot,
autocomplete,
} = options?.form;
} = opts;
return {
class: customClass,
style: customStyles,
Expand Down
5 changes: 3 additions & 2 deletions src/core/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface DynamicForm {
id: string;
fields: FormFields;
fieldOrder?: string[];
options?: FormOptions;
}

export interface ErrorMessage {
Expand Down Expand Up @@ -151,8 +152,8 @@ export type FormControl<T extends InputType> = T & {
};

export interface FormOptions {
customClass?: string | string[] | BindingObject | BindingObject[];
customStyles?: string | string[] | BindingObject | BindingObject[];
customClass?: string | string[] | BindingObject | BindingObject[] | unknown;
customStyles?: string | string[] | BindingObject | BindingObject[] | unknown;
method?: string;
netlify?: boolean;
netlifyHoneypot?: string;
Expand Down