Add a generic, "core/forms" store for forms
See original GitHub issueIssue #1211 required some forms that didn’t warrant creating a bunch of actions, selectors, etc. for their data, but we shouldn’t be using useState to manage form data because it requires passing around state from components and negates a lot of the wins we get from using a Redux-backed datastore.
We talked about this on a call today, and we should have a generic, 'core/forms' data store with a very basic API for getting/setting state across forms in the app.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- There should be a new file,
assets/js/googlesitekit/datastore/forms, that registers a new form data store, under'core/forms'. - It should provide a single selector:
getValue( formName, key ) - It should provide a single action:
setValues( formName, { key: value } )where the second argument is a map of keys to set and their respective values.
Implementation Brief
- Create a new datastore in
assets/js/googlesitekit/datastore/formsthat registers a new form data store, under'core/forms'. - Create a
assets/js/googlesitekit-forms.jsthat registers thecore/formsstore on the default registry. - Add a
googlesitekit-formsasset inAssets.php, similar togooglesitekit-api,googlesitekit-data, etc. that would load thecore/formdatastore into the default registry. - Add a selector:
getValue( formName, key ). This should return the value stored in thestate[ formName ][ key];undefinedif theformNameorkeydoesn’t exist. - Add an action:
setValues( formName, { key: value } )where the second argument is a map of keys to set and their respective values. If the specifiedformNamedoesn’t exist; it should be created.
QA Brief
- Since this is an engineering-only feature for now, specific QA isn’t really needed.
Changelog entry
- Introduce
core/formsdatastore to manage form state.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Forms and Fields in ASP .NET Core | Wake Up And Code!
F is for Forms (and Fields); Tag Helpers for HTML form elements ... You can add additional server-side attributes within the <form> tag...
Read more >tallence/core-forms: A simple and lean formeditor for ... - GitHub
Core Forms. Core Forms is a simple and lean extension for the CoreMedia CMS. Build simple forms in the CoreMedia Studio by your...
Read more >Django Tutorial Part 9: Working with forms - MDN Web Docs
In this tutorial, we're going to show you a few of the ways you can create and work with forms, and in particular,...
Read more >Core Forms HCF-AS Core Buildup - Henry Schein Dental
Shop Henry Schein Dental for Core Forms HCF-AS Core Buildup. Browse our full selection of products and order online.
Read more >Forms - Rasa
Define a form by adding it to the forms section in your domain. The name of the form is also the name of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Sounds good; I’ve updated the IB with your suggestions, with one exception: I don’t think the extra
setValuefunction provides any extra value. The functionality fromsetValue( 'foo', 'bar' )is already present insetValues({ foo: 'bar' }), but the latter is more extensible if one wants to add more items.I don’t think there’s much benefit in having the single-variable one, especially if we’re the only ones using this API for now. But it’s an extra API to maintain without much benefit, so I’d prefer not to add it. (It is easy, but it’s also not super-useful in my opinion.)
Looks good to me! QA ✅