mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 16:51:25 +08:00
FIX: allow array values for custom fields in category params. (#17692)
Previously, when we used `params[:custom_fields].try(:keys)` code it worked for all the custom fields unless it's an array. It created the problem in the discourse-restricted-replies plugin. https://github.com/discourse/discourse-restricted-replies/pull/37#issuecomment-1194207693
This commit is contained in:
@ -371,7 +371,7 @@ class CategoriesController < ApplicationController
|
||||
:read_only_banner,
|
||||
:default_list_filter,
|
||||
:reviewable_by_group_id,
|
||||
custom_fields: [params[:custom_fields].try(:keys)],
|
||||
custom_fields: [custom_field_params],
|
||||
permissions: [*p.try(:keys)],
|
||||
allowed_tags: [],
|
||||
allowed_tag_groups: [],
|
||||
@ -386,6 +386,15 @@ class CategoriesController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def custom_field_params
|
||||
keys = params[:custom_fields].try(:keys)
|
||||
return if keys.blank?
|
||||
|
||||
keys.map do |key|
|
||||
params[:custom_fields][key].is_a?(Array) ? { key => [] } : key
|
||||
end
|
||||
end
|
||||
|
||||
def fetch_category
|
||||
@category = Category.find_by_slug(params[:id]) || Category.find_by(id: params[:id].to_i)
|
||||
raise Discourse::NotFound if @category.blank?
|
||||
|
Reference in New Issue
Block a user