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

Form#setSchema helper method to allow dynamic updating of schema #274

Open
philfreo opened this issue Jul 24, 2013 · 5 comments
Open

Form#setSchema helper method to allow dynamic updating of schema #274

philfreo opened this issue Jul 24, 2013 · 5 comments

Comments

@philfreo
Copy link
Collaborator

I've needed to dynamically change a form schema and then re-render the form.

Right now you can say:

form.schema = newSchema

but then form.fieldsets, form.selectedFields, etc. get out-of-date and have to also be re-set manually.

I'd propose adding a setSchema helper method to Form to make this nicer.

@wyuenho
Copy link
Contributor

wyuenho commented Jul 24, 2013

I'd really prefer it if I could insert or remove fields with methods, which essentially calls createField internally and append or remove from the container. Rerendering is a no go on mobile. I don't thinks people would want the screen to be jumping around, losing focus to field but the keyboard is still hanging around etc as soon as I've picked a value from a select box.

The way I do it currently is to override the Form#render method and #initialize to listen to couple of key change events, the resulting code is quite nasty.

@philfreo
Copy link
Collaborator Author

Let's move discussion about this use case back to #273.

I opened this issue for other use cases where you plan on re-rendering the form anyway (when it's not currently visible) but want to update the schema first.

@philfreo
Copy link
Collaborator Author

Current workaround in the case where you want to take an existing form instance, tweak the schema, and re-display it:

form.schema = _.result(this.model, 'schema'); // or whatever
form.initialize();
form.render();

I'm not sure if calling initialize a 2nd time is OK. If so, this ticket can probably be closed. If not, then we should have a helper method that sets this.fields, this.fieldsets, etc. automatically.

@carofragueiro
Copy link

Hi! Has anyone found an answer to this problem ?

@vip32
Copy link

vip32 commented Mar 28, 2014

form.initialize(); works fine

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

No branches or pull requests

4 participants