1
votes

Hi there i can't belive that redux-forms do not supports nested initial values. Or i do something wrong?

I have reduh form in reducer and i connect in to component throw

@reduxForm({ form: 'singleText', enableReinitialize: true })

Parent component renders it with initial values like:

<TextSingleForm
    initialValues={{...post}}
    onSubmit={::this.submitAction}
    activity={this.activity}
/>

...post is my nested object like:

{ contents: { ru: { text: "1", title: "2" }, en: { text: 1, title: 2 } } }

My field names is contents.ru.text, contents.ru.title and etc.

My main point is i never get the value in my input components but initialValue in redux filled properly HOW COME?

enter image description here

2

2 Answers

0
votes

I found out what happend. When i connect redux-form reducer to store i did it like

{
....
realTimeForm: reduxForm
}

But when i change it to:

{
....
form: reduxForm
}

It became work properly.

I don't have a time for inspect this problem and verify how works redux form inside. If someone knows, please supplement my answer.

0
votes

As I know, it's not recommended to use the multi-level field name like 'content.ru' Why don't use the FormSection?

<FormSection name="content">
  <FormSection name="ru">
      <Field type="text" component="input" name="title" />
      <Field type="text" component="input" name="text" />
  </FormSection>
</FormSection>

The initializing works if you use this format.