dependent-fields-rails
dependent-fields-rails copied to clipboard
Make select2 optional and uncheck hidden fields
I didn't see any dependencies on select2, so I added a check for it.
I also have a requirement to reset/uncheck any checkboxes in the hidden dependent fields. I wasn't sure if this is something you would want or if there's some more customizable way to allow it, so I'm open to any suggestions.
Lastly, I can break these into 2 separate pull requests if you want.
Thanks for the pull request. I will merge the first commit if you split it out into a seperate pull request. I also would consider the second one if unchecking was configurable.
I pulled the first commit out into https://github.com/vollnhals/dependent-fields-rails/pull/10
As for the uncheck, what would you suggest to make it more configurable/usable? Maybe some type of reset config/data-attribute? Would you want to maybe persist the original value and reset it back to that, or is that making it too complicated?
After thinking about it, I think the best way would be to restore the original input states. So instead of just unchecking as you do now, I would reset each input to its original value.
The reset functionality itself would need a flag, so that the default of just hiding remains.