Skip to content

Supplying an ~init=None to a Form.use(.) results in no field updates to the form. #2

@KateChanthakaew

Description

@KateChanthakaew

Description

When a user supplies an ~init=None, subsequent updates made to the form via field.actions.set(value) do not result in form Store updates or changes.

Reproduction

Example File: rescript-fields/examples/login/Login.res

Using the example files and documentation, calling a field.actions.set() from an onChange is not setting values to the form.

Form Instantiation:

 let form = Form.use(. 
    ~context=contextValidate,
    ~init=None,
    ~validateInit=false,
  )

Js.log2("form.field: ", form.field->Field.show)

Handler Verification:

        onChange={e => {
          let target = e->ReactEvent.Form.target
          Js.log2("target.value: ", target["value"])
          target["value"]->form.actions.set
        }}

When typing in the form input fields, there is a target["value"] for every key stroke, but as seen by the form's show method logs, form.field->Field.show no updates are being stored to the form.

VDO:

login_None_NOT-work.mov

Expected Behavior

form.field should always update when input field.action.set(value) is called.

Working Example

If we provide Form.use(.~init=Some(Field.input), ...) and the FieldType is not FieldArray, the form is working as expected. FieldArray's bugs will be noted in a different git-hub issue.

let init: Field.input = {
  username: "",
  password: "",
}

let form = `Form.use(.`
    ~context=contextValidate,
    ~init=some(init),
    ~validateInit=false,
 )

VDO:

login_some-obj_WORK.mov

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions