1
0
Fork 0

Ensure added fields have a key and value

Dieser Commit ist enthalten in:
Angus McLeod 2018-06-05 12:36:56 +10:00
Ursprung 17ba9976c0
Commit 9bbc72481a

Datei anzeigen

@ -60,7 +60,7 @@ class CustomWizard::Builder
if step_template['fields'] && step_template['fields'].length if step_template['fields'] && step_template['fields'].length
step_template['fields'].each do |field| step_template['fields'].each do |field|
validate_field(field, updater) validate_field(field, updater) if field['type'] != 'text-only'
end end
end end
@ -255,29 +255,27 @@ class CustomWizard::Builder
if action['add_fields'] if action['add_fields']
action['add_fields'].each do |field| action['add_fields'].each do |field|
if field['value_custom'] value = field['value_custom'] ? field['value_custom'] : data[field['value']]
value = field['value_custom']
else
value = data[field['value']]
end
key = field['key'] key = field['key']
if key && key.include?('custom_fields') if key && value
keyArr = key.split('.') if key.include?('custom_fields')
keyArr = key.split('.')
if keyArr.length === 3 if keyArr.length === 3
custom_key = keyArr.last custom_key = keyArr.last
type = keyArr.first type = keyArr.first
if type === 'topic' if type === 'topic'
topic_custom_fields[custom_key] = value topic_custom_fields[custom_key] = value
elsif type === 'post' elsif type === 'post'
params[:custom_fields] ||= {} params[:custom_fields] ||= {}
params[:custom_fields][custom_key.to_sym] = value params[:custom_fields][custom_key.to_sym] = value
end
end end
else
params[key.to_sym] = value
end end
else
params[key.to_sym] = value
end end
end end
end end