<% data = action_data @ask_question = data["ask_question"] @categories = data["categories"] @tags = data["tags"] @module_app = data["module_app"] ask_setting = AskSetting.first ask_setting = AskSetting.create() if ask_setting.nil? set_input_name('ask_question') %> <% if data['layout_type'] != 'index' %> <%= render template: "asks/#{data['layout_type']}",:locals => { :data => data, :ask_setting => ask_setting } %> <% else %> <%# javascript_include_tag "/assets/lib/jquery-ui-1.12.1/jquery-ui.min" %> <%# stylesheet_link_tag "/assets/lib/jquery-ui-1.12.1/jquery-ui.min" %> <%= stylesheet_link_tag "custom_field" %> <%# stylesheet_link_tag "jquery-ui-timepicker-addon" %> <%# javascript_include_tag "lib/bootstrap-datetimepicker" %> <%# javascript_include_tag "jquery.ui.datepicker.monthyearpicker" %> <%= javascript_include_tag 'validator' %>
<%= form_for @ask_question, url: asks_path, html: {class: 'form-horizontal'} do |f| %>
<%= f.label nil,t('title'), class: 'control-label required' %>
<%= f.text_field :title,placeholder: t('title'),required: true %>
<% if ask_setting.default_setting['ask_category_id'] %>
<%= f.label :ask_category_id, class: 'control-label required' %>
<% if @categories.count > 1 %> <%= f.select :category_id, @categories.collect{|t| [ t.title, t.id ]} %> <% else %> <%= @categories[0].title rescue '' %> <%= f.hidden_field :category_id, :value => (@categories[0].id.to_s rescue nil) %> <% end %>
<% elsif @categories.count == 1 %> <%= f.hidden_field :category_id, :value => (@categories[0].id.to_s rescue nil) %> <% end %> <% if ask_setting.default_setting['name'] %>
<%= f.label :name, class: 'control-label required' %>
<%= f.text_field :name, data: {"fv-validation" => "required;", "fv-messages" => "必填欄位;"} %>
<% end %> <% if ask_setting.default_setting['sex'] %>
<%= f.label :sex, class: 'control-label required' %>
<% end %>
<%= f.label :mail, class: 'control-label required' %>
<%= f.text_field :mail, data: {"fv-validation" => "required;check_email;", "fv-messages" => "必填欄位;Email不正確;"} %>
<% if ask_setting.default_setting['phone'] %>
<%= f.label :phone, class: 'control-label' %>
<%= f.text_field :phone %>
<% end %> <% if ask_setting.default_setting['appointment'] %>
<%= f.label :appointment, class: 'control-label' %>
<%= f.datetime_picker :appointment %>
<% end %> <%= ask_setting.custom_fields.collect do |k,v| required_pattern = v['required']=='true' ? '*' : '' "
#{show_on_front(k,v)}
" end.join.html_safe %> <% if ask_setting.default_setting['recaptcha'] %>
<%= f.label :recaptcha, class: 'control-label' %>
<%= gotcha_error %> <%= gotcha %>
<% end %>
<%= f.label :agree_show, class: 'control-label' %>
<%= f.check_box :agree_show %>
"> <%= f.submit t('submit'), class: 'btn btn-primary', :id => 'button-mail' %> <%= f.button t('cancel'), type: 'reset', class: 'btn' %>
<% end %>
<% end %>