Giter VIP home page Giter VIP logo

redux-form-submit's Introduction

redux-form-submit

NPM version Build Status Coveralls Status Dependency Status

Adds an async submit action creator to redux-form v6.

The Problem

redux-form, before v6.2.0, doesn't provide a way to submit a form by dispatching an action. This module works like a plugin that exports a submit action creator to do that with a few limitations.

If you are using [email protected] or higher, you probably don't need this, you can just use the built in submit action creator. But, there're cases when that isn't enough. An example is when you want to enable form submission on the server.

Install

npm install --save redux-form-submit

Usage

First, as this is asynchronous, you need to apply the redux-thunk middleware to the store. Then, for every form you want to submit with redux-form-submit you need to expose the config object passed to redux-form. For example:

MyForm.js

import React from 'react'
import { reduxForm, Field } from 'redux-form'

const MyForm = () => (
  <form>
    <Field name="input1" component="input" />
    <Field name="input2" component="input" />
  </form>
)

const onSubmit = (values) => {
  if (values.input1 !== 'right value') {
    throw { input1: 'Please, provide a right value' }
  }
}

// Exports the redux-form config
export const config = {
  form: 'myForm',
  onSubmit
}

export default reduxForm(config)(MyForm)

elsewhere.js

import submit from "redux-form-submit"
import { config } from './MyForm'

dispatch(submit(config))
// or send initial values
dispatch(submit(config, { input1: 'wrong value' }))

Limitations

As this has nothing to do with the form component, it:

  • can't call custom submit methods other than onSubmit;
  • can't pass props to onSubmit, asyncValidate etc.

License

MIT Β© Diego Haz

redux-form-submit's People

Contributors

diegohaz avatar greenkeeper[bot] avatar

Stargazers

Rodrigo Torres avatar Ruslan Kyba avatar Nikollas Betiol avatar Sibelius Seraphini avatar  avatar Grace Haz avatar Chris Larson avatar Andy Chrzaszcz avatar Mads Hargreave avatar

Watchers

James Cloos avatar  avatar  avatar

redux-form-submit's Issues

An in-range update of babel-eslint is breaking the build 🚨

Version 7.2.1 of babel-eslint just got published.

Branch Build failing 🚨
Dependency babel-eslint
Current Version 7.2.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-eslint is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details
Commits

The new version differs by 6 commits .

  • 3cda62e 7.2.1
  • 5626de1 Remove left over eslint 2 estraverse code (#452)
  • b5fb53b Fix type param and interface declaration scoping (#449)
  • f1cee0f Remove lodash dependency (#450)
  • eb05812 Format non-regression errors for legibility (#451)
  • 7972a05 Update README.md with codeFrame option (#448)

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Get fields from formState

If the form is already initialized, the form state already has the fields, so it doesn't need to be passed to the redux-form config.

An in-range update of redux-form is breaking the build 🚨

Version 6.6.0 of redux-form just got published.

Branch Build failing 🚨
Dependency redux-form
Current Version 6.5.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As redux-form is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details
Release Notes v6.6.0

Bug Fixes

  • Exported getFormNames() selector. #2519 #2517
  • Fixed bug in shouldComponentUpdate related to the pure prop. #2575 #2567
  • Fixed rerendering bug in FieldArray. #2544 #2466
  • Avoided unnecessary call to sync validation function. #2584 #2583
  • Added missing entries in exported propTypes #2602
  • Fixed asyncValidating prop type error #2592
  • Bound dispatch to blur and change props given to onSubmit() #2680 #2663
  • Fixed initial submit error state for FieldArrays #2668 #2667
  • Fixed pristine calculation to use deep equality. #2648 #2647
  • Fixed anyTouched bug on UNTOUCH. #2701 #2698
  • Added missing prop types for Field, FieldArray and Fields components. #2709
  • Fixed propTypes error. #2707
  • Replaced usages of for...of construct to fix a problem with IE. 😑 #2724
  • Fixed bug with syncErrors when using Immutable.js. #2721

Features

  • New form-wide onChange callback! #2576 #2530 #883
  • Added meta.submitFailed to FieldArray props. #2586 #2581
  • Added meta.form to FieldArray props #2712
  • New selector for getFormSyncWarnings #2624 #2176
  • New clearSubmitErrors() action. #2615

Coming soon

πŸ₯ I'm currently working on implementing Flow both internally in this library as well as for its public API.

Commits

The new version differs by 36 commits .

  • 97e236a Replaced usages of for...of construct for stupid IE (#2724)
  • 892f45b Fix #2718 (Incorrect way of accessing syncErrors, syncWarnings in ConnectedField, ConnectedFieldArray, ConnectedFields for redux-form/immutable) (#2721)
  • 27211ee Added meta.form to FieldArray props (#2712)
  • a5fc53b Update propTypes.js (#2707)
  • bd4d1fb Add missing prop types for Field, FieldArray and Fields components (#2709)
  • c263c34 Small grammar change (#2702)
  • bb2a8a3 Fixed anyTouched bug on UNTOUCH (#2701)
  • 7066ab3 Update GettingStarted.md (#2695)
  • 9dc03b5 Added Code Climate badge
  • 0c006c0 Replace React Native FAQ (#2691)
  • a2b403d Using yarn again...fingerscrossed
  • a7f5289 Fixed bug with ARRAY_REMOVE not removing sync error (#2683)
  • f3ed0dc Fix #2647 ("pristine" not calculated using deep equality) (#2648)
  • 75d37ad Fix initial submitError state for FieldArrays (#2668)
  • 6d910db Upgraded deps (#2681)

There are 36 commits in total. See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.