Redux-form Wizard http://redux-form.com/6.7.0/examples/wizard/ works great with standard controls from examples. I was trying to integrate more complex controls, such as react-credit-cards enter link description here and have problems passing its state values into the Wizard redux states onSubmit.
The wizard form is very useful in compiling a list of form data together and OnSubmit sends back the full list of captured form data stored in redux. This type of forms are useful for making registrations, payment informations and surveys etc.
Current behavior?
The use case is to use Wizard sample, and in one of the wizard page bundle with credit card information. The Credit card control is wrapper in the same manner as in renderField class provided int the redux-form examples.
The render class calls the credit card control and create 4 input controls to pass the values of the credit card numbers into the control to draw the creditcard, while copying the data into component state. This is all based on the demo code provided by the react-credit-cards team.
render() {
const { name, number, expiry, cvc, focused } = this.state;
return (
<div className="creditCardContainer">
<h1>React Credit Cards</h1>
<div className="creditCardForm">
<CreditCards
number={number}
name={name}
expiry={expiry}
cvc={cvc}
focused={focused}
callback={this.handleCallback}
/>
<form>
<div>
<input
type="tel"
name="number"
placeholder="Card Number"
onKeyUp={this.handleInputChange}
onFocus={this.handleInputFocus}
/>
<div>E.g.: 49..., 51..., 36..., 37...</div>
</div>
<div>
<input
type="text"
name="name"
placeholder="Name"
onKeyUp={this.handleInputChange}
onFocus={this.handleInputFocus}
/>
</div>
<div>
<input
type="tel"
name="expiry"
placeholder="Valid Thru"
onKeyUp={this.handleInputChange}
onFocus={this.handleInputFocus}
/>
<input
type="tel"
name="cvc"
placeholder="CVC"
onKeyUp={this.handleInputChange}
onFocus={this.handleInputFocus}
/>
</div>
</form>
</div>
</div>
);
}
What is the expected behavior?
Need some suggestions as to how to copy the values from the renderCreditCard component states into the Wizard form redux state.
Currently in the Wizard form's onSubmit
class App extends Component {
render() {
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2> {COMPANY} - Sign up form</h2>
</div>
<p className="App-intro">
</p>
**<WizardForm onSubmit={showResults} />**
<div className="App-footer">
<div>Icons made by <a href="http://www.freepik.com" title="Freepik">Freepik</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0">CC 3.0 BY</a></div>
</div>
</div>
);
}
}
the redux data return in the callback function does not contain data from the renderCreditCard component injected into Field.
const showResults = values => {
// append primary key to data
values["id"] = _.uniqueId();
values["number"] <- this is currently undefined
values["names"] <- this is currently undefined
values["expiry"] <- this is currently undefined
values["cvc"] <- this is currently undefined
...
});
when it all works, ideally, the values in the callback shall return number, names, expiry and cvc from Wizard form.
I have tried a couple of methods, including converting renderCreditCard.js input control into Field with component="renderField" without success.
Have anyone tried to integrate react-credit-cards into redux-form? especially in Wizard form pattern? what are some of the ways to propagate the credit card component states back into redux-form?
The issue is track in redux-form issue