Skip to content
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

Field value declaration is different for Entwine and React form fields #755

Open
robbieaverill opened this issue Nov 19, 2018 · 2 comments

Comments

@robbieaverill
Copy link
Contributor

robbieaverill commented Nov 19, 2018

Version: SS 4.3.x-dev

Background

I'm trying to make the silverstripe-tagfield module work correctly in a React form context.

Problem

It looks like Entwine initiated React form fields read their attributes from a different place to that of the React form builder's fields.

For example, to get the tagfield form to correctly populate its saved values, the value attribute must be populated from the getSchemaData() method. For the same field, it must be populated in the getSchemaState() method to work in React forms. In the React case, it puts the value into the Redux store and populates it from there via redux-form.

The issue here is that having the value defined in both places means that it doesn't populate in the React context. The Entwine initiated field doesn't have the redux store available for the form to pull the data out of.

Another example of this is the name attribute. Because the select fields (related: #52) add hidden input fields for each tag selected, the name attribute needs to be an HTML array. To make this work in Entwine context, the name attribute must be added in getSchemaData(), but for React it must be in getAttributes(). If I have the name in getSchemaData() then the React form doesn't work, throwing console errors and some kind of infinite re-rendering loop error.

I can get this field to work in each context just fine by moving the placement of these two pieces of schema data around in the PHP class definition, but I can't get it to work with both at the same time.

@ScopeyNZ
Copy link
Contributor

I think this is quite a critical bug moving forward. Fields like TagField only being usable in either entwine OR react form builder context is pretty inconvenient. Triaging as a high

@robbieaverill
Copy link
Contributor Author

It's quite possible that I've put the schema data/attributes into the wrong methods, to be fair. Either way I think that if it's difficult for me (as a core committer) then there's something to be improved here, even if it's documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants