我已经问了一次这个问题,得到了一些有用的回复,标记为已回答并应用了所有内容.它似乎有效,但遗憾的是它没有.
问题是:不同步骤字段中的表单为空.好吧,我无法判断每一步是否为空,因为我无法在第一步中看到并输入任何内容,因此无法进行下一步,因为验证似乎正在起作用.
我不知道为什么.我坚持在jquery步骤页面上给出的示例:http: //www.jquery-steps.com/Examples#advanced-form
这是相同的代码但是:我的表格是空的.它看起来像这样:

我的代码是:
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<meta charset="utf-8">
<script src="/Scripts/jquery-2.1.1.js"></script>
<script src="/Scripts/jquery.steps.js"></script>
<link href="/Content/jquery.steps.css" rel="stylesheet">
</head>
<body>
<form id="example-advanced-form" action="#">
<h3>Account</h3>
<fieldset>
<legend>Account Information</legend>
<label for="userName-2">User name *</label>
<input id="userName-2" name="userName" type="text" class="required">
<label for="password-2">Password *</label>
<input id="password-2" name="password" type="text" class="required">
<label for="confirm-2">Confirm Password *</label>
<input id="confirm-2" name="confirm" type="text" class="required">
<p>(*) Mandatory</p>
</fieldset>
<h3>Profile</h3>
<fieldset>
<legend>Profile Information</legend>
<label for="name-2">First name *</label>
<input id="name-2" name="name" type="text" class="required">
<label for="surname-2">Last name …Run Code Online (Sandbox Code Playgroud) 我一直在寻找解决这个问题的解决方案.甚至在stackoverflow上有很多建议,我尝试了所有这些,但是我的情况都没有,我不知道为什么.
我在我的服务器上运行了当前版本的RoR [4.1.5],我有一个表单,用户必须选择"time from"和"time to"值.
<p>
<%= f.label :Time %><br>
<%= f.time_select :timefrom, {minute_step: 60} %> to <%= f.time_select :timeto, {minute_step: 60} %>
</p>
Run Code Online (Sandbox Code Playgroud)
我从数据库中获取默认值.为了获取它们,我只收集已输入的最后一个时间值.通常是1小时的时间范围:
<% changetimeto = (Production.select("timeto").last.timeto).strftime("%H:%M") %>
<% changetimefrom = (Production.select("timeto").last.timeto + 3600).strftime("%H:%M") %>
Run Code Online (Sandbox Code Playgroud)
所以我尝试过:
<%= f.time_select :timefrom, {minute_step: 60}, :selected => changetimeto %> to <%= f.time_select :timeto, {minute_step: 60}, :selected => changetimefrom %>
Run Code Online (Sandbox Code Playgroud)
或:value =>或:default =>
但似乎没什么用,它甚至没有给我一个错误.我检查了变量,changetimeto并且changetimefor它们具有正确的值,如"14:00"和"15:00".但正如我所说,它没有做任何事情.
我也尝试用:default => {hours: '14', minutes: '00'}等分别处理小时和分钟,但这也不起作用,甚至不会导致错误.根本不值一提.它仍然默认为实际时间.
有人对我有推荐或暗示吗?