react-redux-form
react-redux-form copied to clipboard
Select defaultValue do not change the modelValue
Setting defaultValue
on a Control.select do not set it to the modelValue
.
After changing the option on the select the value is correctly propagated
@ramiel I cannot reproduce this issue (at least if I understand correctly).
<Control.select defaultValue="foo" model="user.choice">
<option value="">Please choose an option</option>
<option value="foo">Foo!</option>
<option value="bar">Bar!</option>
</Control.select>
The above code will set both the control's view value to "foo"
and the model in the Redux store to user.choice = "foo"
. Is that what you are expecting?
Closing this due to inactivity.
+1 — Does not work for me either on localForm
@iBasit Can you create a reproducible example?
I can share my code with you, which is following:
{row.status === 'open' ? <td style={{width: 70}}><LocalForm className="form-group">
<Control.select defaultValue={row.orderType} model=".orderType" updateOn="change" changeAction={(model, value) => (value !== row.orderType) ? update(row._id, {orderType: value}) : ''} className="form-control form-control-sm">
<option value="">Default Limit + Thrust + Inr</option>
<option value="TAKE_PROFIT_LIMIT">TPS Take Profit STOP (Thrust + Inr)</option>
<option value="STOP_LOSS_LIMIT">TLS Take Loss STOP (Thrust + Inr)</option>
<option value="TAKE_PROFIT">TP Take Profit on Limit (Thrust ignored)</option>
<option value="STOP_LOSS">TL Take Loss on Limit (Thrust ignored)</option>
<option value="LIMIT">Limit (exact price) (Thrust ignored)</option>
</Control.select></LocalForm></td> : <td></td>}
before this code, I have other sibling localForms, which I just use the value with placeholder, since defaultValue was not working, but for drop down I can't do that.
other siblings
{row.status === 'open' ? <td style={{width: 70}}><LocalForm className="form-group"><Control.text model=".limit" updateOn="blur" changeAction={(model, value) => (value && value !== row.limit) ? update(row._id, {limit: parseFloat(value)}) : ''} placeholder={row.limit} className="form-control form-control-sm" /></LocalForm></td> : <td></td>}
{row.status === 'open' ? <td style={{width: 70}}><LocalForm className="form-group"><Control.text model=".thrust" updateOn="blur" changeAction={(model, value) => (value && value !== row.thrust) ? update(row._id, {thrust: parseFloat(value)}) : ''} placeholder={row.thrust} className="form-control form-control-sm" /></LocalForm></td> : <td></td>}
{row.status === 'open' ? <td style={{width: 70}}><LocalForm className="form-group"><Control.text model=".incrementBy" updateOn="blur" changeAction={(model, value) => (value && value !== row.incrementBy) ? update(row._id, {incrementBy: parseFloat(value)}) : ''} placeholder={row.incrementBy} className="form-control form-control-sm" /></LocalForm></td> : <td></td>}
"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-redux": "^5.0.6",
"react-redux-form": "^1.16.3",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-router-redux": "next",
"redux": "^3.7.2",
"redux-socket.io": "^1.4.0",
"redux-thunk": "^2.2.0",
"sanitize.css": "^5.0.0",
"socket.io-client": "^2.0.4",
},
btw I'm creating many forms, just to update each row value, since I can't put localForm on <tr>
tag.
do you know when can we expect a fix for this? This is very important for our project or any project.
If you know the probable fix, feel free to open a PR. I can't guarantee when I will be able to have the time to investigate or fix this, but I can guarantee that all good PRs will be merged and released promptly.