HTML表单命名约定的名称 [英] Names of HTML form naming conventions

查看:185
本文介绍了HTML表单命名约定的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Rails和CakePHP1.2中,表单往往包括具有如下名称的输入元素:

 < input name =comment [author]/> 

name属性中使用的符号是否有正式名称?



同样,在CakePHP1.1中,我相信这看起来像这样:

 < input name =comment / author/> 

同样,在name属性中使用的符号是否有正式名称?

解决方案

在蛋糕php,命名方案是多维数组访问格式,虽然我不知道你会叫什么。多维数组键控?



官方php文档调用它方括号符号



基本上,我不知道cakephp有一个特定的名称为这...这是因为它是简单的括号符号的键盘数组访问。



这是cakephp文档的一个例子。它说明了在cakephp中用括号符号命名元素,以及如何使用它来预填充值。



使用蛋糕php FormHelper我们创建一个隐藏的id字段:

  echo $ this-> Form-> hidden('id'):

 <! -  data来自$ this-> request-> data  - 
< input name =data [User] [id]id =UserIdtype =hidden/>

假设 data [User] [id] code>为 10 ,ID为 UserId 的输入值为10。 p>

In Rails and CakePHP1.2, forms tend to include input elements with names like the following:

<input name="comment[author]" />

Is there a formal name for the notation used in the "name" attribute?

Likewise, in CakePHP1.1 I do believe that the same would have looked like this:

<input name="comment/author" />

Again, is there a formal name for the notation used in the "name" attribute?

解决方案

in cake php, the naming scheme is in multidimensional array access format, though i'm not really sure what you'd call that. multidimensional array keying?

official php docs call it "square bracket notation"

Basically, I'm not sure that cakephp has a specific name for this... This is because it is simply 'bracket notation' for keyed array access.

Here's an example from the cakephp docs. It illustrates naming elements with bracket notation in cakephp, and how this is used to pre-populate values.

using cake php FormHelper we create a hidden id field:

echo $this->Form->hidden('id'):

this outputs the following:

<!-- data comes from $this->request->data -->
<input name="data[User][id]" id="UserId" type="hidden" />

Assuming that the value held by data[User][id] is 10, the input with an ID of UserId will have a value of 10.

这篇关于HTML表单命名约定的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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