Compare commits

...

2 Commits

Author SHA1 Message Date
邱博亞 df25703375 修復自動填值時,會覆蓋name 2023-06-05 23:03:58 +08:00
邱博亞 d1266dcfa1 修復寄信問題 2023-06-05 22:55:26 +08:00
2 changed files with 27 additions and 4 deletions

View File

@ -530,7 +530,9 @@ class AsksController < ApplicationController
old_input = old_.find('input, select');
if(new_input.length != 0 && old_input.length != 0){
if(new_input.length == old_input.length){
old_.clone().replaceAll(new_);
var old_clone = old_.clone();
old_clone.find('input, select').attr('name', new_input.attr('name'));
old_clone.replaceAll(new_);
}
}
}

View File

@ -15,6 +15,10 @@
yes_trans = t('ask.yes')
no_trans = t('ask.no')
locale = I18n.locale.to_s
ask_setting = AskCategorySetting.enabled.where(category_id: question.category_id.to_s).first
ask_setting = AskSetting.first if ask_setting.nil?
is_cat_record = (ask_setting.class == AskCategorySetting)
tmp_ask_cat_id = (is_cat_record ? ask_setting.id.to_s : '')
%>
<% @data['disp_fields_infos'].each do |f, field_info| %>
<% next if f == 'recaptcha' %>
@ -24,8 +28,25 @@
is_cat = false
is_custom = false
if f.include?("@")
f = field_info["key"]
field = f
is_custom = true
is_field_enable = false
if field.start_with?("default@")
f = is_cat_record ? field : field[8..-1]
v = ask_setting.custom_fields[f]
if v
is_field_enable = true
end
elsif field.start_with?("custom@") && is_cat_record
if field.include?(tmp_ask_cat_id)
f = field[8+tmp_ask_cat_id.length..-1]
v = ask_setting.custom_fields[f]
if v
is_field_enable = true
end
end
end
next if !is_field_enable
elsif f == 'ask_category_id'
f = 'category_id'
is_cat = true
@ -50,9 +71,9 @@
elsif type == "date"
val = val["datetime"].values[0].values rescue []
if val.count == 2
val = val[0].gsub('-', '/') + " ~ " + val[1].gsub('-', '/')
val = val[0].to_s.gsub('-', '/') + " ~ " + val[1].to_s.gsub('-', '/')
else
val = val[0].gsub('-', '/')
val = val[0].to_s.gsub('-', '/')
end
elsif type == "instructions"
val = field_info["instructions"][locale].to_s.html_safe rescue ""