Skip to content

Commit

Permalink
Add support for radio buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
latortuga committed Aug 17, 2023
1 parent 19e0701 commit d8eb374
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 8 deletions.
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
- [X] Add a hidden field with a signed string of all the fields used in the form builder
- [X] Look at how cookies are decrypted to decrypt server-side
- [X] Patch ActionController::Parameters to have auto_permit! and use the shape from the form
- [ ] Add radio button support
- [ ] Handle signature verification errors in a customizable way (error/log/silent)
- [ ] For upgrades, we can suggest / allow a setting to try to catch the exception that SP raises and try to call auto_permit! and don't raise.
- [ ] Support SimpleForm / other form builders
Expand Down
7 changes: 1 addition & 6 deletions lib/auto_strong_parameters/auto_form_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module AutoStrongParameters::AutoFormParams
TRACKED_FIELDS = %w(
search_field telephone_field date_field time_field datetime_field
month_field week_field url_field email_field number_field range_field
file_field password_field text_area text_field
file_field password_field text_area text_field radio_button
)

TRACKED_FIELDS.each do |name|
Expand All @@ -26,11 +26,6 @@ def #{name}(*args)
RUBY_EVAL
end

# TODO
def radio_button(*)
super
end

private

def _asp_track_field(field)
Expand Down
2 changes: 2 additions & 0 deletions test/apps/basic_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class BasicController < ActionController::Base
<%= f.number_field :age %>
<%= f.range_field :years_of_experience %>
<%= f.password_field :password %>
<%= f.radio_button :preferred_phone_os, :iphone %>
<%= f.radio_button :preferred_phone_os, :android %>
<%= f.fields_for :parents do |parf| %>
<%= parf.text_field :name %>
<%= parf.text_area :job %>
Expand Down
2 changes: 1 addition & 1 deletion test/apps/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class User

attr_accessor :name, :email, :description, :phone, :dob, :lunch_time,
:confirmed_at, :birth_month, :birthday_week, :favorite_url, :age,
:years_of_experience, :password
:years_of_experience, :password, :preferred_phone_os

def parents
@parents ||= [Parent.new]
Expand Down
1 change: 1 addition & 0 deletions test/auto_form_params_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def permitted_keys
"age",
"years_of_experience",
"password",
"preferred_phone_os",
{
"parents_attributes"=>[
"name",
Expand Down

0 comments on commit d8eb374

Please sign in to comment.