Skip to content
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

Fix html option settings for objects that have multiple values #386

Merged
merged 2 commits into from
Aug 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions bullet_train-super_scaffolding/lib/scaffolding/transformer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -841,14 +841,22 @@ def valid_#{collection_name}
field_options[:color_picker_options] = "t('#{child.pluralize.underscore}.fields.#{name}.options')"
end

# When rendering a super_select element we need to use `html_options: {multiple: true}`,
# but all other fields simply use `multiple: true` to work.
if is_multiple
if type == "super_select"
field_options[:multiple] = "true"
else
field_attributes[:multiple] = "true"
end
end

valid_values = if is_id
"valid_#{name_without_id.pluralize}"
elsif is_ids
"valid_#{collection_name}"
end

field_options[:multiple] = "true" if is_multiple

# https://stackoverflow.com/questions/21582464/is-there-a-ruby-hashto-s-equivalent-for-the-new-hash-syntax
if field_options.any? || options.any?
field_options_key = if ["buttons", "super_select", "options"].include?(type)
Expand Down