You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 23, 2022. It is now read-only.
### How do you add conditional class names based on field state?
6
+
7
+
Use the `mapProps={{...}}` property on `<Control>` components to set any props on the control component based on field state, like this:
8
+
9
+
```jsx
10
+
<Control.text
11
+
model="user.firstName"
12
+
mapProps={{
13
+
className: ({fieldValue}) =>fieldValue.focus
14
+
?'focused'
15
+
:''
16
+
}}
17
+
/>
18
+
```
19
+
20
+
The props that are provided to each function value in your `mapProps` mapping are:
21
+
-`modelValue`
22
+
-`fieldValue`
23
+
-`onFocus`
24
+
-`onBlur`
25
+
-`onChange`
26
+
27
+
as well as other additional props:
28
+
- all props on the `<Control>`
29
+
- all props on the `controlProps={{...}}` prop (if any)
30
+
-`onKeyPress`
31
+
-`viewValue`
32
+
33
+
### How do you validate across fields?
34
+
35
+
Validation across fields becomes a higher form-level concern, which follows Redux's general tree-structure data flow pattern. If you want a reusable group of fields that are validated, you can **nest forms** as long as you set the form's `component="..."` prop to something other than `"form"` (because you can't nest forms in HTML). [See this issue response for more information.](https://github.com/davidkpiano/react-redux-form/issues/545#issuecomment-261944846) Here's an example:
These examples are implementations of the examples from [Redux-Form](http://redux-form.com/6.2.1/examples), shown for comparison.
4
+
5
+
### Simple Form
6
+
7
+
<pdata-height="300"data-theme-id="13607"data-slug-hash="e384d9c541679c8141979c590ac24d80"data-default-tab="js,result"data-user="davidkpiano"data-embed-version="2"data-pen-title="RRF - Simple Form"data-editable="true"class="codepen">See the Pen <ahref="http://codepen.io/davidkpiano/pen/e384d9c541679c8141979c590ac24d80/">RRF - Simple Form</a> by David Khourshid (<ahref="http://codepen.io/davidkpiano">@davidkpiano</a>) on <ahref="http://codepen.io">CodePen</a>.</p>
<pdata-height="300"data-theme-id="13607"data-slug-hash="381bb491da76e74305f5d2851644fbbf"data-default-tab="js,result"data-user="davidkpiano"data-embed-version="2"data-pen-title="RRF - Synchronous Validation"data-editable="true"class="codepen">See the Pen <ahref="http://codepen.io/davidkpiano/pen/381bb491da76e74305f5d2851644fbbf/">RRF - Synchronous Validation</a> by David Khourshid (<ahref="http://codepen.io/davidkpiano">@davidkpiano</a>) on <ahref="http://codepen.io">CodePen</a>.</p>
<pdata-height="300"data-theme-id="13607"data-slug-hash="c683e0cf7ee54736b49b2ce30aba956f"data-default-tab="js,result"data-user="davidkpiano"data-embed-version="2"data-pen-title="RRF - Submit Validation"data-editable="true"class="codepen">See the Pen <ahref="http://codepen.io/davidkpiano/pen/c683e0cf7ee54736b49b2ce30aba956f/">RRF - Submit Validation</a> by David Khourshid (<ahref="http://codepen.io/davidkpiano">@davidkpiano</a>) on <ahref="http://codepen.io">CodePen</a>.</p>
0 commit comments