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

Commit

Permalink
Merge pull request #212 from asigloo/bugfix/form-options
Browse files Browse the repository at this point in the history
Bugfix/form options
  • Loading branch information
alvarosabu authored Dec 30, 2020
2 parents 1cce47d + 0cbc9c5 commit a557fd0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
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

0 comments on commit a557fd0

Please sign in to comment.