feat: implement form submit button limit (#47)
* feat: implement form submit button limit * feat: add submit control to form
This commit is contained in:
parent
f1485808c9
commit
97128a0816
2 changed files with 8 additions and 3 deletions
|
@ -1,15 +1,18 @@
|
|||
---
|
||||
import type { FormGroup } from './core';
|
||||
import type { FormControl, FormGroup } from './core';
|
||||
import Field from './components/Field.astro';
|
||||
import FieldSet from './components/FieldSet.astro';
|
||||
|
||||
export interface Props {
|
||||
submitControl?: FormControl;
|
||||
formGroups: FormGroup[];
|
||||
}
|
||||
|
||||
const { formGroups } = Astro.props;
|
||||
const { submitControl, formGroups } = Astro.props;
|
||||
---
|
||||
<form class="light">
|
||||
{formGroups?.map((group) => <FieldSet group={group} />)}
|
||||
{submitControl && (<Field control={submitControl} />)}
|
||||
</form>
|
||||
|
||||
<style>
|
||||
|
|
|
@ -7,7 +7,9 @@ export class FormGroup {
|
|||
|
||||
constructor(controls: FormControlBase[], name = '') {
|
||||
this.name = name;
|
||||
this.controls = controls.map((control) => new FormControl(control));
|
||||
this.controls = controls
|
||||
.filter(control => control.type !== 'submit')
|
||||
.map(control => new FormControl(control));
|
||||
}
|
||||
|
||||
get(name: string): FormControl | undefined {
|
||||
|
|
Loading…
Reference in a new issue