From 8ddfbcc7c780e12ce60fbfd1ce3390b4bc35f9aa Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 13 Jun 2019 15:59:31 +0800 Subject: [PATCH] training: add form check --- app/controllers/trainings_controller.rb | 2 +- app/views/trainings/enroll.html.erb | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/controllers/trainings_controller.rb b/app/controllers/trainings_controller.rb index 7b9164b5..40757ade 100644 --- a/app/controllers/trainings_controller.rb +++ b/app/controllers/trainings_controller.rb @@ -279,7 +279,7 @@ class TrainingsController < ApplicationController end def find_tag_id - @tag_id = params[:id] + @tag_id = params[:tag_id] || params[:id] Rails.logger.info("##########TAG_ID:#{@tag_id}") @training_type = @tag_id == "aeee0601_2019" ? 3 : @tag_id == "ceeaa06_2019" ? 4 : 0 render_404 if @training_type == 0 diff --git a/app/views/trainings/enroll.html.erb b/app/views/trainings/enroll.html.erb index 4def0abe..d6543a23 100644 --- a/app/views/trainings/enroll.html.erb +++ b/app/views/trainings/enroll.html.erb @@ -126,7 +126,7 @@

<%= @training_title %>

<%= form_for @training do |f| %> - <%= hidden_field_tag(:id, @tag_id) %> + <%= hidden_field_tag(:tag_id, @tag_id) %>

基本信息

  • @@ -304,6 +304,19 @@ return; } + <% if @training_type == 3 %> + var trainingCategory = $('input[type="radio"][name="training_category"]:checked').val(); + if (trainingCategory == undefined || trainingCategory == '') { + alert('请选择培训类型'); + return; + } + + if ($("input[type='checkbox'][name='research_field[]']:checked").length == 0) { + alert('请选择授课类型/研究领域'); + return; + } + <% end %> + if (userphone == '') { alert("请输入手机号码"); return;