为什么WHATWG不允许HTML 4和HTML5中的嵌套表单? [英] Why WHATWG disallows nested forms in HTML 4 and HTML5?

查看:142
本文介绍了为什么WHATWG不允许HTML 4和HTML5中的嵌套表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么WHATWG不允许在HTML 4和HTML5中嵌套表单



编辑
问题最初在< a href =https://stackoverflow.com/questions/597596/how-do-you-overcome-the-html-form-nesting-limitation>你如何克服html表格嵌套限制?

总之,作者说:
您正在制作一个博客应用程序,并且您有一个表单,其中包含一些用于创建新帖子的字段,一个带有动作的工具栏,如保存删除,取消...
唯一的问题是按删除提交服务器上的所有表单域,即使此操作唯一需要的是带有后端标识的隐藏输入。



所以,这是一个关于一个优雅的解决方案(没有JavaScript)的问题,用于表单中的多个按钮,以提交不同的输入字段集合像几种形式可以允许的那样)从用户角度将UI排成单个实体(表单)。



讨论:几乎不可能将元素的屏幕位置与文档中的位置完全分开。

发现有趣的笔记 http://anderwald.info/internet/nesting-form- (X)HTML不允许像form> form这样的嵌套形式,但允许form> fieldset> form,W3验证器认为它是有效的,但浏览器有这样的嵌套。

解决方案

就HTML5(草案规范)而言,情况几乎没有那么明确正如David Dorward所建议的那样。什么是真实的是,没有办法在text / html序列化中以向后兼容的方式指定嵌套表单,而无需在标记中添加新的分隔表单的方式。



另一方面,在应用程序/ xhtml + xml序列化中,不仅可以标记嵌套表单,而且HTML5也会有一定的长度(
http://dev.w3.org/html5/spec/forms.html#form-owner )指定在此应该发生的事情案件。此外,围绕最新版本的FireFox,Opera,Chrome和Safari以及IE9平台预览版进行的快速测试显示,它们都是按照HTML5指定的。



所以,它可能在HTML5内容模型中有效,但事实并非如此。什么决定什么是有效的,什么不在很大程度上取决于用例。到目前为止,没有人向WHATWG或W3C HTML WG提供足够引人注目的用例来使嵌套表单成为有效的HTML5的一部分。


Why does the WHATWG disallow nested forms in HTML 4 and HTML5?

EDIT: Problem is originally described at How do you overcome the html form nesting limitation?

In short author says: You are making a blog app and you have a form with some fields for creating a new post and a toolbar with "actions" like "Save", "Delete", "Cancel"... The only problem is that pressing "Delete", will submit ALL the form fields on the server even though the only thing needed for this action is a Hidden input with the post-id.

So, it is a question about an elegant solution (without JavaScript) for several buttons in a form to submit different sets of input fields (like several forms could allow) and to line up UI into single entity ("form") from user perspective.

Comment from that discussion: it's almost impossible to completely separate the elements' screen position from their position in the document.

EDIT: I found interesting note http://anderwald.info/internet/nesting-form-tags-in-xhtml/ - that (X)HTML disallows nesting forms like "form > form", but allows "form > fieldset > form", W3 validator says it is valid, but browsers have bugs with such nesting.

解决方案

As far as HTML5 (the draft spec) goes, the situation is not nearly as clear cut as David Dorward suggests. What is true, is that there's no way that nested forms can be specified in the text/html serialization in a backward-compatible way without adding a new way of delimiting forms in markup.

On the other hand, in the application/xhtml+xml serialization, it's not only possible to markup nested forms, but HTML5 goes to some lengths ( http://dev.w3.org/html5/spec/forms.html#form-owner ) to specify what should happen in this case. Further, a quick test around the latest versions of FireFox, Opera, Chrome, and Safari, plus IE9 platform preview shows that they all do what HTML5 specifies.

So, it could have been valid in the HTML5 content model, but it isn't. What determines what is valid and what isn't rests largely on use-cases. So far, no one has provided a sufficiently compelling use case to WHATWG or the W3C HTML WG for making nested forms a part of valid HTML5.

这篇关于为什么WHATWG不允许HTML 4和HTML5中的嵌套表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆