redux-form

Redux form with self creating inputs

走远了吗. 提交于 2019-11-30 14:07:16
I'm trying to create a redux form (using redux-form) that can dynamically create it's own inputs. I am having trouble figuring out how to make redux-form aware of the new fields that have been created. Is it possible to dynamically change the fields prop that redux-form passes in within the form component itself? Am I thinking about this wrong? Here is what I am working with. class AddCustomer extends Component { render() { class Form extends Component { constructor(props, context) { super(props, context) this.state = { inputsToAdd: [] }; } handleAddInput() { let inputsToAdd = this.state

Redux-Form update field value from external interaction

核能气质少年 提交于 2019-11-30 12:23:49
I have a redux-form connected to my application state and everything seems to work great. I can fetch data and load it into my form, then submit data and get the metadata I want... However, I have a custom interaction (a color picker) that needs to change the value of a managed Field on the fly. Everything I try will change the screen, but not the redux form state i.e. when I submit the form I just get the original field data and not the new data shown in the form. The version below is passing the field props to the component and trying to use the ColorSelect component state as the field value

Redux form defaultValue

独自空忆成欢 提交于 2019-11-30 11:17:57
How to set defaultValue to input component? <Field name={`${prize}.rank`} defaultValue={index} component={Input} type='text'/> I tried like above but my fields are empty. I'm trying to create fieldArray (dynamic forms): {fields.map((prize, index) => <div key={index} className="fieldArray-container relative border-bottom" style={{paddingTop: 35}}> <small className="fieldArray-title marginBottom20">Prize {index + 1} <button type="button" title="Remove prize" className="btn btn-link absolute-link right" onClick={() => fields.remove(index)}>Delete</button> </small> <div className="row"> <div

Dynamically load initialValues in Redux Form

流过昼夜 提交于 2019-11-30 09:06:24
Using the example of initializingFromState within Redux-Form, I am trying to set this up dynamically. This is to edit a particular book in a list of books, and is using a simple api set up in express.js. The full container is below. I somehow need to pass in initialValues , within the mapStateToProps function. In the example, it is done via a static object, but I can't work out how to use the information I have pulled in via fetchBook , and pass it to initialValues . Container: import React, { Component, PropTypes } from 'react'; import { reduxForm } from 'redux-form'; import { connect } from

Using redux-form I'm losing focus after typing the first character

 ̄綄美尐妖づ 提交于 2019-11-30 06:43:12
I'm using redux-form and on blur validation. After I type the first character into an input element, it loses focus and I have to click in it again to continue typing. It only does this with the first character. Subsequent characters types remains focuses. Here's my basic sign in form example: import React, { Component } from 'react'; import { connect } from 'react-redux'; import { Field, reduxForm } from 'redux-form'; import * as actions from '../actions/authActions'; require('../../styles/signin.scss'); class SignIn extends Component { handleFormSubmit({ email, password }) { this.props

Set value in field in redux form

徘徊边缘 提交于 2019-11-30 06:24:10
I have redux form having dropdown and text fields. On dropdown change i have to update the other fields. The other fields are using custom component example So the structure is like. 1. component having form 2. Field component. Now i googled and found few things to update the field but not able to do it. What i tried 1. Adding state in the field like below in value. Does not work. <Field name="accountno" value="this.state.accountno" component={InputText} placeholder="Number" /> Tried disptach but not able to use it. Getting error for no dispatch i prop type this.props.dispatch(change('form',

How do you pass in a dynamic form name in redux form?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 06:07:02
Im trying to use this code to pass a dynamic form name into reduxForm. Here is the code that I found: let FormAddress = compose(connect((state, props) => ({form: props.form})), reduxForm({destroyOnUnmount: false, asyncBlurFields: []}))(ValidationForm); From this article: https://github.com/erikras/redux-form/issues/603#issuecomment-254271319 But I'm not really sure whats going on. This is how I'm currently doing it: const formName = 'shippingAddress'; const form = reduxForm({ form: formName }); export default connect(mapStateToProps)(CityStateZip); But I would like to be able to pass it in

React Native + Redux Form - Use keyboard next button to go to next TextInput field

孤街浪徒 提交于 2019-11-30 05:28:48
问题 I'm using Redux Form (RF) in a React Native application. Everything works fine but I can not figure out how to get the refs from the Field input to go to the next input field with Redux Form. Without RF this solution would work just fine. Here is my code: class RenderInput extends Component { const { input, nextField, refs, meta: { touched, error, warning }, input: { onChange } } = this.props render() { return ( <Input returnKeyType = {'next'} onChangeText={onChange} onBlur={input.onBlur}

Make server validation using redux-form and Fetch API

混江龙づ霸主 提交于 2019-11-30 02:33:30
How to make server-side validation using redux-form and Fetch API? There are " Submit Validation " demo provided in the docs which says that recommended way to do server side validation is to return a promise from the onSubmit function. But where should I place that promise? As I understood onSubmit function should be my action. <form onSubmit={this.props.addWidget}>... Where this.props.addWidget is actually my action, provided below. import fetch from 'isomorphic-fetch'; ... function fetchAddWidget(widget, workspace) { return dispatch => { dispatch(requestAddWidget(widget, workspace)); return

Redux-Form update field value from external interaction

情到浓时终转凉″ 提交于 2019-11-29 17:50:34
问题 I have a redux-form connected to my application state and everything seems to work great. I can fetch data and load it into my form, then submit data and get the metadata I want... However, I have a custom interaction (a color picker) that needs to change the value of a managed Field on the fly. Everything I try will change the screen, but not the redux form state i.e. when I submit the form I just get the original field data and not the new data shown in the form. The version below is