Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: nested objects/arrays #2897

Merged
merged 13 commits into from
Sep 16, 2020
Merged

feat: nested objects/arrays #2897

merged 13 commits into from
Sep 16, 2020

Conversation

logaretm
Copy link
Owner

@logaretm logaretm commented Sep 15, 2020

🔎 Overview

This PR adds the ability to structure form fields into nested objects #2890

Todo:

  • Nested Objects
  • Support for initial values
  • Nested Arrays
  • Cleaning up nested values (after unmount)
  • A way to opt-out of the nesting
  • Write Docs

Example:

<Form @submit="onSubmit">
  <Field name="user.name" rules="required"  />
  <Field name="user.password" type="password" rules="required"  />
  <Field name="user.social[0]" type="url" rules="required"  />
  <Field name="user.social[1]" type="url" rules="required"  />

  <button id="submit">Submit</button>
</Form>

Submitting the above form will result in the following values:

{
  user: {
    name: "John Doe",
    password: "123456",
    social: [
       "link1",
       "link2"
    ]
  }
}

Issues affected

closes #2890

@logaretm logaretm changed the title feat: added ds store to gitignore feat: nested objects/arrays Sep 15, 2020
@logaretm logaretm linked an issue Sep 15, 2020 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Sep 16, 2020

Codecov Report

Merging #2897 into next will decrease coverage by 0.09%.
The diff coverage is 97.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##             next    #2897      +/-   ##
==========================================
- Coverage   98.06%   97.97%   -0.10%     
==========================================
  Files          47       47              
  Lines         880      936      +56     
  Branches      192      206      +14     
==========================================
+ Hits          863      917      +54     
- Misses         16       18       +2     
  Partials        1        1              
Impacted Files Coverage Δ
packages/core/src/Form.ts 94.73% <ø> (ø)
packages/core/src/utils/common.ts 96.00% <96.00%> (ø)
packages/core/src/useField.ts 98.37% <100.00%> (ø)
packages/core/src/useForm.ts 98.64% <100.00%> (ø)
packages/core/src/utils/assertions.ts 100.00% <100.00%> (ø)
packages/core/src/utils/index.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 21dda88...50e4806. Read the comment docs.

@logaretm logaretm merged commit 8d161a1 into next Sep 16, 2020
@logaretm logaretm deleted the feat/nested-values branch September 16, 2020 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[V4]: support for structured objects as InitialValues of a form
1 participant