silverstripe-admin icon indicating copy to clipboard operation
silverstripe-admin copied to clipboard

Form fields with HTML array syntax in the name don't get mapped properly into redux-form state

Open robbieaverill opened this issue 5 years ago • 0 comments

Version: 4.3.x-dev

If I have a field with HTML array syntax in its name, the form schema maps it as a key value (like all other fields) into the redux state, but redux-form doesn't match the value from the state into the form field when it renders it.

$fields = FieldList::create(
    TextField::create('myfield[123]', null, 'my value')
);

Redux state (real world example rather than the above code):

image

When I update the form field I notice that the redux state is updated with a nested data structure instead:

image

I assume that our implementation of redux-form state population needs to be tweaked to detect fields with HTML array fields and break them up into nested data structures before they get written to the state, so it complies with the schema that redux-form uses to write back to the state when a field name is changed.

We've worked around this in https://github.com/dnadesign/silverstripe-elemental/pull/386 by using underscores and using pattern matching in the input request vars when the form is posted back rather than looping through as a structured array.

robbieaverill avatar Sep 12 '18 22:09 robbieaverill