注册界面失败填写信息继续保留

修改注册见面企业提交失败姓、名内容错误Bug
This commit is contained in:
linhk 2014-08-06 14:41:22 +08:00
parent d8964d81a8
commit 23c9d5381e
2 changed files with 51 additions and 6 deletions

View File

@ -103,6 +103,13 @@ class AccountController < ApplicationController
def register
# @root_path="/home/pdl/redmine-2.3.2-0/apache2/"
#
@cache_identityy = params[:identity]||"" #身份
@cache_no = params[:no]||"" #学号
@cache_technical_title = params[:technical_title]||"" #教师职称
@cache_province = params[:province]||"" #省份
@cache_city = params[:city]||"" #城市
@cache_enterprise_name = params[:enterprise_name]||"" #企业
(redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration]
if request.get?
session[:auth_source_registration] = nil
@ -112,8 +119,8 @@ class AccountController < ApplicationController
@user = User.new
@user.safe_attributes = user_params
if params[:identity] == "2" # 2 企业
@user.firstname = params[:enterprise_name]
@user.lastname = l(:field_enterprise)
#@user.firstname = params[:enterprise_name]
#@user.lastname = l(:field_enterprise)
end
@user.admin = false
@user.register

View File

@ -193,7 +193,40 @@
</script>
<script type="text/javascript" language="javascript">
window.onload = function(){
var identity = "<%= @cache_identityy %>";
var no = "<%= @cache_no %>";
var technical_title = "<%= @cache_technical_title %>";
var province = "<%= @cache_province %>";
var city = "<%= @cache_city %>";
var enterprise_name = "<%= @cache_enterprise_name %>";
//还原身份
if(identity!=null&&identity!=""){
$('#userIdentity').children("option[value='"+identity+"']").attr("selected","selected");
showtechnical_title(identity, document.getElementById('userTechnical_title'));
if(identity=="0"){
//还原教师职称
$('#userTechnical_title').children("option[value='"+technical_title+"']").attr("selected","selected");
}else if(identity=="1"){
//还原学号
$("input[id='no']").attr("value",no);
}
}
//还原地区
if(province!=null&&province!=""){
$("#userProvince").children("option[value='"+province+"']").attr("selected","selected");
showcity(province, document.getElementById('userCity'));
$("select[id='userCity']").children("option[value='"+city+"']").attr("selected","selected");
}
//还原企业名
if(enterprise_name!=null&&enterprise_name!=""){
$("input[id='enterprise_name']").attr("value",enterprise_name);
}
}
function showtechnical_title(identity, technical_titleField) {
var technical_titleOptions = null;
switch (identity) {
case '0' :
@ -202,7 +235,7 @@
$('#name').show()
$('#enterprise').hide()
$('#gender').show()
var technical_titleOptions = new Array(
technical_titleOptions = new Array(
"<%= l(:label_technicl_title_professor) %>", "<%= l(:label_technicl_title_associate_professor) %>", "<%= l(:label_technicl_title_lecturer) %>", "<%= l(:label_technicl_title_teaching_assistant) %>");
break;
@ -234,7 +267,11 @@
break;
}
technical_titleField.options.length = 0;
if(technical_titleOptions == null){
return;
}
for (var i = 0; i < technical_titleOptions.length; i++) {
technical_titleField.options[i] = new Option(technical_titleOptions[i], technical_titleOptions[i]);
/*
@ -242,7 +279,8 @@
{
//alert("here put City ok!");
document.oblogform["city"].selectedIndex = i;
}*/
}
*/
}
}
</script>