-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Add a hidden field on the collection_radio_buttons #18303
Add a hidden field on the collection_radio_buttons #18303
Conversation
@@ -14,7 +14,8 @@ def radio_button(extra_html_options={}) | |||
end | |||
|
|||
def render(&block) | |||
render_collection do |item, value, text, default_html_options| | |||
options = @options.stringify_keys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can simplify the implementation of this method and collection_check_boxes moving it render_collection
. Also I don't think we need to stringify in this case.
86a22b6
to
131cc3b
Compare
@rafaelfranca I updated the code following your suggestions. About |
131cc3b
to
7b571d6
Compare
3a42911
to
8831820
Compare
@rafaelfranca when you have some time could you please review 😄 |
8831820
to
682c70a
Compare
@rafaelfranca fixed the conflicts, when you have some time could you please review |
682c70a
to
d37149b
Compare
@rafaelfranca please review when you have some time 😄 |
d37149b
to
f2d158d
Compare
@rafaelfranca I rebased again to fix the conflicts, please review when you have some time.Is there anything I can do to help? @carlosantoniodasilva maybe you can review this 😄 |
end | ||
end | ||
|
||
def hidden_field #:nodoc: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @maurogeorge – I'm 👍 with this PR 😀
Since you added def hidden_field
, could the one already defined in collection_check_boxes.rb be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @claudiob great to hear this 😄
You are right I can remove the mentioned hidden_field
. I updated the code and rebased.
f2d158d
to
08e956e
Compare
@template_object.check_box(@object_name, @method_name, html_options, @value, nil) | ||
end | ||
end | ||
|
||
def render(&block) | ||
rendered_collection = render_collection do |item, value, text, default_html_options| | ||
default_html_options[:multiple] = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple is not being handled anymore with your refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rafaelfranca I moved the multiple options to the check_box
it is covered by the tests, if I remove this line I got some broken tests
08e956e
to
696f619
Compare
|
||
Example: | ||
|
||
* Add a `hidden_field` on the `collection_radio_buttons` to avoid raise a error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is something strange in this change… it should only show your new lines, not replace the existing one.
Did you accidentally edit the next CHANGELOG message too?
If you review this, also fix avoid raise
to avoid raising
😉
This will avoid a error be raised when the only input on the form is the `collection_radio_buttons`.
696f619
to
578bc4b
Compare
@claudiob @rafaelfranca thanks a lot for the review ❤️ 😍 |
…idden_field Add a hidden field on the collection_radio_buttons
Thanks for the merge ❤️ |
Rails has had this functionality since version 5[0] so it makes sense for it to be supported here. This change uses the same keyword, include_hidden, as Rails so should feel familiar to users. [0] rails/rails#18303
Rails has had this functionality since version 5[0] so it makes sense for it to be supported here. This change uses the same keyword, include_hidden, as Rails so should feel familiar to users. [0] rails/rails#18303
The same behavior that occurs on file_field(#17947) occurs with the
collection_radio_buttons
.