kuroda / vue-rails-form-builder

A custom Rails form builder for Vue.js
MIT License
80 stars 9 forks source link

Added option to camelize object and attributes. #5

Open tiagocassio opened 6 years ago

kuroda commented 6 years ago

@tiagocassio

Thanks. Could you add some description to the README.md?

tiagocassio commented 6 years ago

Done! Thanks!

kuroda commented 6 years ago

I checked your code on my local PC.

I noticed that when I use fields_for, the attribute names do not get camelized.

Unfortunately, I can not find any solution for this problem.

kuroda commented 6 years ago

Now I think it is rather inconvenient for developers to specify camelize option for each form_for and form_with. It should be configured globally.

But I don't any idea how to allow this configuration on this gem.

tiagocassio commented 6 years ago

I confess that i was not expecting this. I will try at night, i'm out now.

sirwolfgang commented 6 years ago

This type of option should also be in the initializer, like jBuilder. This would also maintain backward compatibility for people need to upgrade, in the same manner, that Rails does; If the default was to change.

If your interested, I took this PR and upgraded my fork. https://github.com/sirwolfgang/vue-rails-form-builder

Edited: I forgot how you have to change a ton of tiny settings to get everything in default rails to be camel case.

sirwolfgang commented 6 years ago

The issue you are seeing with setting the options here is that camelize is being set on the form and not the tags. You have to store the form options on the builder, then use it for each tag like this: https://github.com/sirwolfgang/vue-rails-form-builder/commit/574fd66e8f7a589d47109687fdb981656b9323a4