-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merging passed initialValues from the schema and from props #332
Comments
@Hyperkid123 What do you think? |
@skateman I was under the impression that initialValue from schema has a higher priority. I will need to think about this for a moment. |
Having the higher priority from the component actually makes more sense, but they should overlap and merge. |
And how do you think the merge should look like? Can you provide a simple example? |
So this setup: const schema = {
component: 'text-field',
name: 'name',
},
{
component: 'text-field',
name: 'address',
initialValue: 'Foo street'
},
{
component: 'text-field',
name: 'country',
initialValue: 'Czech Republic'
};
const values = {
name: 'John Doe',
address: 'Bar street',
}
<FormRender schema={schema} initialValues={values}>; Should return with the initial values: {
name: 'John Doe',
address: 'Bar street',
country: 'Czech Republic',
} |
@skateman and that is not happening right now? That is how it should work. |
Nope, it doesn't |
Huh, that is strange. Ok, I will take a look at what is going on there. This is expected behavior and I was under the impression that it is working. Apparently not. |
@skateman co I just tried the example you posted and I am getting the exact result you wanted. Can you provide more info please? |
Maybe the problem is with dotted field names? It's happening on my openstack form in MiQ. |
Lets try that |
const schema = {fields: [{
component: 'text-field',
name: 'name',
},
{
component: 'text-field',
name: 'bar.address',
initialValue: 'Foo street'
},
{
component: 'text-field',
name: 'country',
initialValue: 'Czech Republic'
}]};
const values = {
name: 'John Doe',
bar: {
address: 'Bar street',
}
} same result as before |
Maybe try update to latest version? There might have been a bug in previous. or did you try to construct the nested value like this:
|
Still doesn't work with the latest, I have |
Also it doesn't work for non-dotted fields, it just ignores any |
Hmm. Still can't reproduce. Do you think you could create an example on code sandbox? No need to use any mapper just have some basic inputs. |
I'm afraid it's cause by the fact that the form is being rendered on-demand 😕 so it might be miq-specific... |
@skateman is it happening in one specific field? Or is there some sort of pattern? |
It's a pattern, every field with an |
Well, that is a big one... Can we check it together on Monday? |
Wednesday the soonest, but sure. It's a tough one ... |
@skateman closing this seems like the issue was on the MIQ side. Feel free to re-open this issue if you disagree. |
I know that the
initialValues
passed to theFormRender
component have a higher priority. However, if this attribute is set on the component, it ignores anyinitialValue
attributes defined on the field level in the schema, even those which aren't set on the component level.I discussed this with @rvsia and he said this is a bug, the two levels should be merged with the component level as priority.
The text was updated successfully, but these errors were encountered: