Skip to content

Conversation

@burnt43
Copy link
Contributor

@burnt43 burnt43 commented Jul 10, 2014

when using collection_check_boxes if you select none of the check boxes nothing will update. I've added a hidden field with value "" so if you don't select any check boxes it will update. This is like the behavior for collection_select.

@carloslopes
Copy link
Member

I think it's better if we add an option to collection_check_boxes called unchecked_value and when the user pass it, we create the hidden field with the provided value.

If the user pass nothing, the hidden field isn't created. What do you think @burnt43 ?

@burnt43
Copy link
Contributor Author

burnt43 commented Jul 14, 2014

Speaking only for my use case, I can't think of a time where I'd want either:

  1. the unchecked_value be anything other than an empty string
  2. the unchecked_value to not exist

Adding the unchecked_value would make it more flexible, but I'm not sure if its necessary. I do not know how others are using collection_check_boxes. It seems awkward to have to adding unchecked_value: "" to my collection_check_boxes when I expected this to be the default behavior.

@burnt43 burnt43 changed the title Fix for Issue #106. Added hidden field for collection_check_boxes Fix for Issue #106. Fix for using check_box with bootstrap_form_tag (no object) Jul 15, 2014
@burnt43 burnt43 changed the title Fix for Issue #106. Fix for using check_box with bootstrap_form_tag (no object) Fix for Issue #106. Jul 15, 2014
@carloslopes
Copy link
Member

@burnt43 I agree with you, if this hidden field doesn't exist the changed could not be saved correctly on server side.

But, I think we should add an option to accept other value for the hidden field.

Can you work on this?

@burnt43
Copy link
Contributor Author

burnt43 commented Aug 29, 2014

@carloslopes sorry for the late reply, but yes I can work on this.

@carloslopes
Copy link
Member

No problem! :)

@potenza
Copy link
Member

potenza commented Sep 11, 2014

@burnt43 @carloslopes I actually ran into this bug for the first time today. I think we should go ahead with @burnt43's original fix and then possibly add the ability to accept a value for the hidden field later.

This would also allow me to release a new version of the gem this week...

@carloslopes
Copy link
Member

@potenza ok, go on. The hidden field with an empty value is the default behavior of these types of helpers on rails too.

But, we can open an issue to add this functionality in the future.

The tests are broken too. Will you @potenza or @burnt43 fix them? If you are busy, I can work on them.

@potenza
Copy link
Member

potenza commented Sep 11, 2014

@carloslopes sounds good. I can work on this later tonight and then hopefully release a new gem as well.

@carloslopes
Copy link
Member

@potenza ok, if you need some help, just ask me!

@potenza
Copy link
Member

potenza commented Sep 12, 2014

@carloslopes Thanks! I actually got pulled into something else tonight that I'm still trying to wrap up. Feel like taking care of this one?

@carloslopes
Copy link
Member

Of course! But I will work on it tomorrow, ok? It's 00:15hr here in Brazil
now.
On Sep 12, 2014 12:11 AM, "Stephen Potenza" notifications@github.com
wrote:

@carloslopes https://github.com/carloslopes Thanks! I actually got
pulled into something else tonight that I'm still trying to wrap up. Feel
like taking care of this one?


Reply to this email directly or view it on GitHub
#116 (comment)
.

@potenza
Copy link
Member

potenza commented Sep 12, 2014

of course! thanks again.

@carloslopes
Copy link
Member

I started work on this today and I found a problem.

The hidden field is generated with the name object[:attribute] but the right is object[:attribute][]. I'm looking for the best way to solve this, instead of create the name by hand.

@potenza
Copy link
Member

potenza commented Sep 16, 2014

@carloslopes I tested these changes locally and it seemed to create the correct hidden field for me:

<input id="subscriber_mailing_list_ids" multiple="multiple" name="subscriber[mailing_list_ids][]" type="hidden" value="">

@potenza potenza merged commit 98410a6 into bootstrap-ruby:master Sep 16, 2014
potenza added a commit that referenced this pull request Sep 16, 2014
@carloslopes
Copy link
Member

@potenza yeah, you are right! I removed that multiple option here and this was causing the missing [] on input name.

My bad!

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

Successfully merging this pull request may close these issues.

3 participants