Skip to content

Commit 15b3d20

Browse files
RawInitialValue is now being processed before registering.
defaultValue is now being set on field registration. InitialValue -> DefaultValue @ FieldState.
1 parent 0dd4d78 commit 15b3d20

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

packages/simplr-forms-core/src/abstractions/base-field.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,11 @@ export abstract class BaseField<TProps extends FieldProps, TState extends BaseFi
273273
throw new Error(`simplr-forms-core: Duplicate field id '${this.FieldId}'`);
274274
}
275275

276-
const initialValue = this.RawInitialValue;
276+
const initialValue = this.ProcessValueBeforeStore(this.RawInitialValue);
277277
this.FormStore.RegisterField(
278278
this.FieldId,
279279
initialValue,
280+
this.DefaultValue,
280281
this.props,
281282
this.FieldsGroupId
282283
);

packages/simplr-forms-core/src/contracts/field.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface FieldProps {
2020
}
2121

2222
export interface FieldState {
23-
InitialValue: FieldValue;
23+
DefaultValue: FieldValue;
2424
Value: FieldValue;
2525
Error?: FormErrorRecord;
2626
Touched: boolean;

packages/simplr-forms-core/src/stores/form-store.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@ export class FormStore extends ActionEmitter {
6767
public RegisterField(
6868
fieldId: string,
6969
initialValue: FieldValue,
70+
defaultValue: FieldValue,
7071
props?: FieldStateProps,
7172
fieldsGroupId?: string
7273
) {
7374
// Construct field state
7475
let fieldState = this.GetInitialFieldState();
75-
fieldState.InitialValue = initialValue;
76+
fieldState.DefaultValue = defaultValue;
7677
fieldState.Value = initialValue;
7778

7879
if (props != null) {
@@ -216,7 +217,7 @@ export class FormStore extends ActionEmitter {
216217

217218
protected GetInitialFieldState(): FieldState {
218219
return {
219-
InitialValue: undefined,
220+
DefaultValue: undefined,
220221
Value: undefined,
221222
Touched: false,
222223
Pristine: true,

0 commit comments

Comments
 (0)