-
Notifications
You must be signed in to change notification settings - Fork 95
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
Method to refresh form inputs on model update? #6
Comments
Frankly, I never thought about your use case before. And all the built in fields are optimised for performance. The worst case would to build a customized field that supports two way binding given that you only have one or two fields that need to be updated from outside. |
OK, I probably need to add a refresh method to ComposedComponent since there could be a lot of fields depending on the editor type. Will get back to you with a PR when I have a solution. |
Actually I'm struggling with the same issue, I think it can be a really popular use case. In order to achieve that, In ComposedComponent you can add componentWillReceiveProps and set the state, based on new model. Also props have to be changed from defaultValue to value, in some components like Text or Number. I think it would be a great feature to have, and I can submit a pull request at any moment. @stevehu what do you think about that? |
Sounds good to me. We just need to make sure that array and fieldset work with refresh. Thanks |
I've also ran into a situation where I need my form to update, because of a model change. What is the status of this feature? |
Hello! I worked out a solution by altering the Select component's state when it receives props. Let me know if that solution would suit you, and I'll have a PR ready! Eventually, other components could be updated that way too. |
@foxdb We are looking for a solution to this problem. Is anybody working on it? |
@foxdb I think your solution should work if it applies to all types of field. I am looking forward to the PR. Thanks. |
@foxdb Thanks for your help. We have several PRs recently and one of the PR got a small issue. I am still waiting for the developer to take a look and get it fixed. I don't know if we should have a release with a small issue. If someone is waiting for this feature, I will release it immediately with a comment. |
In waiting, you can use a specific schemaform property for forcing rerendering. For example, use a reset key which changes of value and is associated to the schemaform. ...
handleReset = () => this.setState({ reset: ! this.state.reset, model: this.props.model /* default model */ });
...
// rendering method
const { reset, model } = this.state;
return (
<SchemaForm key={this.state.reset} model={this.state.model} />
);
... |
Is there a method for refreshing form values or re-rendering the SchemaForm when the model updates? It seems the SchemaForm doesn't react (no pun intended) to model changes (for example when routing to another item, which in turn updates the model).
Not sure if it's an issue with material-ui or react-schema-form though.
Excellent work, by the way!
The text was updated successfully, but these errors were encountered: