question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature request] Populate forms with $formkit.load() and only pick schema data

See original GitHub issue

Describe the feature

While we populate forms with the value prop it would also be nice to load API responses directly into <Formkit> and only pick the defined schema values / structure.

The downside of the :value prop is that all values that have been added will be directly transfered as form data when submitting the form (even if they are not in the schema).

With a new $formkit.load method it will be easy to populate data by e.g. API’s and send only the fields you’ve defined.

onMounted(async () => {
      const { data } = await $fetch('/projects')
      $formkit.load.load(data)
})

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
GustavoFenillicommented, Sep 27, 2022

Just as also a clarification it is already possible to do what you want with the current API using a plugin. this is a really simple way of doing only to the form level ( also not a plugin ) to just show you that removing fields before setting is possible using node.input and node.hook.commit ( pardon my crude example as it is just an example )

I think there is indeed a good point on adding a new function or extending the node.input API to do that automatically to improve DX tho.

0reactions
maartenvanhunselcommented, Sep 27, 2022

@GustavoFenilli ahaa that’s perfect if we can extend the current api like this: $formkit.get('nodeId').setMatchingValues(dataObjectFromServer).

Thanks for the clarification.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inputs — Essentials ⚡️ FormKit — Vue Forms, Supercharged
The form type provides a host of features including value collection, initial value setting, form submission, error handling, loading states, and more.
Read more >
Custom Inputs — Advanced ⚡️ FormKit
Create your own inputs that automatically inherit FormKit's value-added features such as validation, error messages, data modeling, grouping, labels, ...
Read more >
Your first form — Getting-started ⚡️ FormKit
Let's start by creating our first FormKit form! We'll learn some of FormKit's key features and how they benefit you. We'll also pick...
Read more >
Build a multi-step form — Guides ⚡️ FormKit
Follow this guide to learn how to build a multi-step form with FormKit. ... Aggregate form data from all the steps into a...
Read more >
FormKit ⚡️ Vue Forms — Supercharged
FormKit is a free and open-source comprehensive form development framework for Vue 3. Build industry-leading forms, 10x faster.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found