diff --git a/examples/simple-form/src/pages/button.astro b/examples/simple-form/src/pages/button.astro new file mode 100644 index 0000000..294de97 --- /dev/null +++ b/examples/simple-form/src/pages/button.astro @@ -0,0 +1,28 @@ +--- +import {BButton, BindForm} from '@astro-utils/forms/forms.js'; +import 'bootstrap/dist/css/bootstrap.css'; +import {Button} from 'reactstrap'; +import Layout from '../layouts/Layout.astro'; + + +let showSubmitText: string; + +function formSubmit() { + Astro.locals.session.counter ??= 0; + Astro.locals.session.counter++; + showSubmitText = `You clicked ${Astro.locals.session.counter} times`; +} +--- + + + + Submit + {showSubmitText} + + + + {showSubmitText} + + + + diff --git a/examples/simple-form/src/pages/index.astro b/examples/simple-form/src/pages/index.astro index 6092e0f..3635281 100644 --- a/examples/simple-form/src/pages/index.astro +++ b/examples/simple-form/src/pages/index.astro @@ -1,6 +1,6 @@ --- import Layout from '../layouts/Layout.astro'; -import {BButton, Bind, BindForm, BInput} from '@astro-utils/forms/forms.js'; +import {BButton, Bind, BindForm, BInput, FormErrors} from '@astro-utils/forms/forms.js'; import {Button} from 'reactstrap'; import 'bootstrap/dist/css/bootstrap.css'; @@ -16,7 +16,9 @@ function formSubmit(){ --- + {showSubmitText} + {Astro.locals.session.counter &&

You have submitted {Astro.locals.session.counter} times.

} diff --git a/packages/forms/components/form/BButton.astro b/packages/forms/components/form/BButton.astro index 8ba4ecb..3d62326 100644 --- a/packages/forms/components/form/BButton.astro +++ b/packages/forms/components/form/BButton.astro @@ -14,16 +14,19 @@ export interface Props