Skip to content

Commit cd1ec68

Browse files
committed
fix(input): readonly state
1 parent 85164e2 commit cd1ec68

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

examples/simple-form/src/pages/state-check.astro

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import Layout from '../layouts/Layout.astro';
55
const bind = Bind({});
66
77
bind.on.newState = () => {
8-
bind.num = 9;
9-
}
10-
8+
bind.num = [1, 2, 3, 9];
9+
};
1110
1211
function onSubmit() {
1312
console.log(bind.num);
@@ -16,7 +15,7 @@ function onSubmit() {
1615

1716
<Layout title='Test Select'>
1817
<BindForm bind={bind} key='page'>
19-
{bind.num}
18+
{bind.num?.map((value, index) => <BInput name={`num[${index}]`} placeholder={value} />)}
2019
<BButton whenFormOK onClick={onSubmit}>Submit</BButton>
2120
</BindForm>
2221
</Layout>

packages/forms/src/components-control/input-parse.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ type InputTypes =
3737

3838
type ExtendedInputTypes = InputTypes | 'int';
3939

40-
export async function getInputValue(astro: AstroGlobal, bindId: string) {
40+
export async function getInputValue(astro: AstroGlobal, bindId: string, bind: BindForm<any>) {
4141
const { value, name, readonly } = astro.props;
4242
if (readonly) {
43-
return value;
43+
return getProperty(bind, name, value);
4444
}
4545

4646
return await getFormValue(astro.request, bindId + name);
@@ -49,7 +49,7 @@ export async function getInputValue(astro: AstroGlobal, bindId: string) {
4949
export async function validateFormInput(astro: AstroGlobal, bind: BindForm<any>, bindId: string) {
5050
const { type, value: originalValue, minlength, maxlength, pattern, required, name, errorMessage, validate } = astro.props;
5151

52-
const parseValue: any = await getInputValue(astro, bindId);
52+
const parseValue: any = await getInputValue(astro, bindId, bind);
5353
const aboutInput = new AboutFormName(bind, name, parseValue, errorMessage);
5454

5555
// validate filed exits

0 commit comments

Comments
 (0)