【发布时间】:2010-12-29 02:12:53
【问题描述】:
在我的项目中,我有一个注册表单。
我的 HTML 看起来像
<form method="post" action="/users">
<div style="margin: 0pt; padding: 0pt;">
<input type="hidden" value="lDHrKRC2ENhRKcaoBR4XGfzri/MY09PjqVDvHRtC0D4=" name="authenticity_token"/>
</div>
<p><label for="login">Login</label>
<input type="text" size="30" name="user[login]" id="user_login"/></p>
<p><label for="email">Email</label>
<input type="text" size="30" name="user[email]" id="user_email"/></p>
<p><label for="password">Password</label>
<input type="password" size="30" name="user[password]" id="user_password"/></p>
<p><label for="password_confirmation">Confirm Password</label>
<input type="password" size="30" name="user[password_confirmation]" id="user_password_confirmation"/></p>
<p><input type="submit" value="Sign up" name="commit"/></p>
</form>
现在通过提交我的代码如下所示的空表单来生成错误:
<form method="post" action="/users">
<div style="margin: 0pt; padding: 0pt;"><input type="hidden" value="lDHrKRC2ENhRKcaoBR4XGfzri/MY09PjqVDvHRtC0D4=" name="authenticity_token"/>
</div>
<p><label for="login">Login</label>
</p><div class="fieldWithErrors"><input type="text" value="hg" size="30" name="user[login]" id="user_login"/></div>
<p><label for="email">Email</label>
</p><div class="fieldWithErrors"><input type="text" value="gh" size="30" name="user[email]" id="user_email"/></div>
<p><label for="password">Password</label>
</p><div class="fieldWithErrors"><input type="password" value="gh" size="30" name="user[password]" id="user_password"/></div>
<p><label for="password_confirmation">Confirm Password</label>
<input type="password" value="gh" size="30" name="user[password_confirmation]" id="user_password_confirmation"/></p>
<p><input type="submit" value="Sign up" name="commit"/></p>
</form>
这会破坏我的布局。 有解决办法吗
<input type="text" value="gh" size="30" name="user[email]" class="fieldWithErrors" id="user_email"/>
而不是
<div class="fieldWithErrors"><input type="text" value="gh" size="30" name="user[email]" id="user_email"/></div>
?
【问题讨论】:
标签: ruby-on-rails