Skip to content

Commit

Permalink
fix: default bind
Browse files Browse the repository at this point in the history
  • Loading branch information
ido-pluto committed Dec 26, 2023
1 parent aad2fec commit e2c9184
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 8 additions & 5 deletions packages/forms/src/components-control/form-utils/bind-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@ export class BindForm<T> {
return this._plugins.find(x => x.constructor.name == name);
}

finishFormValidation() {
defaults() {
this._defaults && Object.assign(this, this._defaults);
}

/**
* @internal
*/
__finishFormValidation() {
for (const plugin of this._plugins) {
plugin.createValidation();
}
}

defaults() {
this._defaults && Object.assign(this, this._defaults);
}

/**
* @internal
*/
Expand Down
5 changes: 3 additions & 2 deletions packages/forms/src/components/form/BindForm.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
import {asyncContext} from '@astro-utils/context';
import getContext from '@astro-utils/context';
import ViewStateManager from '../../components-control/form-utils/view-state.js';
import Bind from '../../components-control/form-utils/bind-form.js';
export interface Props {
bind?: any;
state?: boolean | string[];
}
const {viewStates} = getContext(Astro, '@astro-utils/forms');
const {bind} = Astro.props;
const {bind = Bind()} = Astro.props;
const context = {executeAfter: [], method: Astro.request.method, bind, tempBindValues: {}, elementsState: {}};
const viewState = new ViewStateManager(bind, context.elementsState, Astro, viewStates.counter++);
await viewState.loadState();
let htmlSolt = await asyncContext(() => Astro.slots.render('default'), Astro, {name: '@astro-utils/forms', context});
bind?.finishFormValidation();
bind.__finishFormValidation();
for (const func of context.executeAfter) {
await (func as any)();
}
Expand Down

0 comments on commit e2c9184

Please sign in to comment.