simple_form icon indicating copy to clipboard operation
simple_form copied to clipboard

Validation error overrides specified :collection =>

Open iscott opened this issue 14 years ago • 3 comments

I have the following line in my view: f.association :company, :collection => @companies

This loads a collection of companies filtered based on the current tenant. If a validation error occurs on that form (for example a company is not selected from the dropdown), the form reloads - with the validation error, but the companies dropbox now contains every company instead of the filtered list for that tenant.

iscott avatar Jun 25 '12 06:06 iscott

Ok, it looks like I didn't have the @companies variable defined in the create action of the controller. The rails form helper would give a nil error in this case, but simple_form just loads the association without any error. It would be nice to have an error in this instance to avoid accidental leakage. Thanks.

iscott avatar Jun 25 '12 06:06 iscott

We have merged this recently: 2db82867b569824968e2131210981e868b834e62, that changes the way it handles it, instead of rendering the entire collection, it'll render an empty one. That's based on some discussion from #595. Thanks!

carlosantoniodasilva avatar Jun 25 '12 12:06 carlosantoniodasilva

Just the answer I was looking for, solved my problem right away.

el-noppo avatar Feb 15 '13 21:02 el-noppo