使用表内的 form_tag 创建 2 个表单(rails)
我想制作一个表格,其中一列是登录,另一列是注册 使用纯html,就像
<table id="logIn-signIn">
<tr>
<td class="hd">LOGIN :</td>
<td class="hd">SIGN-UP :</td>
</tr>
<tr>
<td>
Email :
<input type="text" name="email" value="Email" />
</td>
<td>
First name :
<input type="text" name="firstName" value="First name"/>
</td>
</tr>
<tr>
<td>
Password :
<input type="text" name="password" value="Password"/>
</td>
<td>
Family name :
<input type="text" name="familytName" value="Family name"/>
</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
<td>
Email :
<input type="text" name="email" value="Email" />
</td>
</tr>
<tr>
<td></td>
<td>
Password :
<input type="text" name="email" value="Choose a password" />
</td>
</tr>
</table>
问题是每一列将使用不同的字段(一个用于登录,一个用于注册),因此每个列都需要不同的form_for - 一个用于新用户,一个用于新会话,
因为html表结构是行而不是列,我无法分离 form_for 块。
我如何在 1 个表中使用 2 个不同的 form_for 块?
谢谢
I'd like to make a table which one column is the is the login and the other is the sign up
using pure html it is something like
<table id="logIn-signIn">
<tr>
<td class="hd">LOGIN :</td>
<td class="hd">SIGN-UP :</td>
</tr>
<tr>
<td>
Email :
<input type="text" name="email" value="Email" />
</td>
<td>
First name :
<input type="text" name="firstName" value="First name"/>
</td>
</tr>
<tr>
<td>
Password :
<input type="text" name="password" value="Password"/>
</td>
<td>
Family name :
<input type="text" name="familytName" value="Family name"/>
</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
<td>
Email :
<input type="text" name="email" value="Email" />
</td>
</tr>
<tr>
<td></td>
<td>
Password :
<input type="text" name="email" value="Choose a password" />
</td>
</tr>
</table>
The problem is that each column will use different fields (one for logging in and one for sign up) so each needs different form_for - one for new users and one for new session
Since the html table structure goes by rows and not columns, I can't separate the form_for blocks..
How would I use 2 different form_for blocks inside 1 table?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
注意:正如评论者所指出的,使用
divs
和css
使这更容易,但我假设您确实需要使用tables
由于某种原因。使用嵌套表格布局。
外表用于结构 - 它将有一行和两列。在左侧单元格中,仅为登录表单构建一个表格,并在右侧单元格中为注册表单构建一个表格。
form_for
标记将位于嵌套表格之外,但位于布局表格的单元格内。NOTE: as the commenters have pointed out, using
divs
andcss
makes this easier, but I assume you really need to usetables
for some reason.Use a nested table layout.
The outer table is for the structure - it will have one row and two columns. Inside the left cell, build a table for just the login form, and in the right cell, build a table for the sign up form. The
form_for
tags will be outside of the nested tables, but inside the cell of the layout table.