react-final-form

Use server-side validation response in react-admin

北城余情 提交于 2020-02-28 07:13:06
问题 In my app using react-admin I have a few forms where the validation must be performed on the server side. My API (implemented with api-platform) returns a 400 response with a key in its body that contains an array of the constraint violations, keyed to the field names, so the information is there to provide field-by-field error messages. This issue is the same explored in this old question. However, since react-admin moved from redux-form to react-final-form, solutions based on an error saga

why value is not set on dropdown in react js (allready set value props)?

为君一笑 提交于 2020-02-06 08:04:05
问题 I am taking help from this link how to set value in dropdown in react js? set the value of dropdown .but it is not setting value in dropdown. I am getting dropdown data after few seconds 3000 and then I need to set value on dropdown expected output Aland Islands should be selected. { key: "ax", value: "ax", text: "Aland Islands" }, here is my code https://codesandbox.io/s/sharp-rhodes-140fm const SingleSelectAutoComplete = props => { const { onSearchChange, input, label, data, value } = props

In React Final Form, providing initialValues to nested fields

时光怂恿深爱的人放手 提交于 2020-01-03 05:28:11
问题 I'm working with React Final Form, and for some reason, when I try to pass initial values to its initialValues prop, it doesn't work if the keys I use are in the format 'key6.value' - the Field with that name stays empty. It does, however, work if the format doesn't have the . in the middle, e.g. 'key6value' . Why doesn't initialValues work for these nested fields (fields with names that have the .)? And what can I do to make it pass the initialValues ? I've tested this thoroughly to make

Conditional dropdowns with react-select in react-final-form initialized from the state

非 Y 不嫁゛ 提交于 2020-01-01 18:19:28
问题 I'm using react-select and react-final-form for conditional dropdowns, where options for the second select are provided by a <PickOptions/> component based on the value of the first select (thanks to this SO answer). Here is the component: /** Changes options and clears field B when field A changes */ const PickOptions = ({ a, b, optionsMap, children }) => { const aField = useField(a, { subscription: { value: 1 } }); const bField = useField(b, { subscription: {} }); const aValue = aField

React-final-form ignores Field validate property change

﹥>﹥吖頭↗ 提交于 2019-12-24 07:46:50
问题 On click on a checkbox, I'm changing the "validate" property of another field. The problem is the following: "validate" field is changed and I can see it in React inspector, but react-final-form calls an old validator. You can see a demo here: https://codesandbox.io/embed/nny0zxz4rm If you click on the checkbox and then Submit - form will be submitted and validator ignored. If you click the checkbox twice - nonrequired field will prevent form submit. I can't change the validator's code and

How To Mock redux-promise-listener Middleware And final-form

China☆狼群 提交于 2019-12-14 04:22:11
问题 I setup react-redux-promise-listener (repo) for react-final-form via author instructions. Now, I'm having trouble mocking it for testing. I'm getting error: The redux-promise-listener middleware is not installed I've tried applying middleware within the test provider: // app/frontend/__mocks__/TestReduxProvider.js import React from 'react'; import { createStore, applyMiddleware } from 'redux'; import { Provider as ReduxProvider } from 'react-redux'; import { compose, setDisplayName,

How to implement a custom component with two values in react-final-form

被刻印的时光 ゝ 提交于 2019-12-11 16:32:50
问题 I have a custom component which renders two values, mainOkved as a string and additionalOkveds as an array. In order to use it without react-final-form I simply add these values to the state and update them onSelect : onSelectOkved(mainOkved, additionalOkveds) { this.setState({ mainOkved: mainOkved, additionalOkveds: additionalOkveds }); } The component itself looks like this: <OkvedSelector mainOkved={this.state.mainOkved} additionalOkveds={this.state.additionalOkveds} onSelect={this

Issue to submit CSV file to DB via POST Axios & React-Final-Form

徘徊边缘 提交于 2019-12-11 15:27:32
问题 I need to save the content of a CSV into a database table by using React-Final-Form and Axios. I have tried to create a simple HTML without using Final-Form or Axios and the submission to the DB works fine. The problem is when I try to pass the content of the CSV to a function which will handle the POST call. See code below: import React, { Fragment } from "react"; import { Form, Field } from "react-final-form"; import createDecorators from "final-form-focus"; const handleSubmitOnClick = file

Mutate state based on existing fields

≯℡__Kan透↙ 提交于 2019-12-11 07:33:21
问题 With React-Final-Form, I am creating a control that allows users to be listed ina directory if a radio button is clicked. In the click handler, I wish to auto-populate a textbox with the user's first and last names. I am doing this with a mutator, and I'm hoping I can get confirmation that I am doing this correctly, as I couldn't find documentation about the lastFieldState property I'm leveraging: setDisplayName: (args, state, utils) => { const { firstname, lastname } = state.fields; const