First, create the View. I decided to create a table view of my nodes with some basic information:
首先，新建view，我决定新建表格样式的view列出node的一些基本信息。
Not much to say here. Just your typical, run-of-the-mill View. You'll replace the title field with our custom form field.
这里没什么可说的，就是平常的view。你即将要使用自定义的表单字段来更新node的标题字段。

Next, create a starting module with a .info and a .module file. I called mine module "view_form" (in real life, I'd probably choose a name less likely to collide with another module).
接下来，创建一个空的带有.info和.module文件的模块。我把这模块命名为“view_form”(现实中，我可能会选一个不那么容易和其他模块名产生冲突的名字)

This code implements "hook_views_api" and tells Views where it can find your "[module].views.inc" file, which will contain my Views' hook implementations. As is typical, the "view_form.views.inc" file is located in the "views" directory under the root of the module.
这段代码实现了“hook_views_api”这个钩子函数，并告诉Views那里可以找到[模块名].views.inc文件。这个[模块名].views.inc文件将会包含views的钩子函数实现。一般情况下，"view_form.views.inc"这个文件将会放在本模块的根目录的views文件夹里.

The view_form.views.inc contains just one Views' hook implementation:
view_form.views.inc文件里,只有一个views的钩子函数实现.

Use "hook_views_data_alter" to add a new "field" to the "node" element provided by Views. The node element primarily consists of properties and fields defined by the Schema and Field APIs. But other modules can add "dummy" fields--fields that don't provide any data of their own but process and render values already defined by the Node and Field modules.
使用view提供的"hook_views_data_alter"，对node元素添加一个“字段”。Node元素基本上包含了Schema和Field API中定义的属性和字段。但其他的模块可以添加“虚假的”字段，这些字段不需要存储数据，但会加工并输出Node和Field模块已经定义好的值。

The practical effect of "view_form_views_data_alter" is that--after clearing caches--there will be one new field to add to our node Views in the Views UI:
"view_form_views_data_alter"钩子函数的实际影响就是，在清楚缓存之后，一个新的字段会被添加到View的UI界面里node字段列表。

You could go ahead and add that field--but Views will complain because it can't find the code for the "view_form_field_handler_title_edit" field handler.
你可以照着步骤添加这个字段，但views会抱怨找不到"view_form_field_handler_title_edit"这个字段的处理程序。

So go ahead and create a "view_form_field_handler_title_edit.inc" file inside of the "views" sub-directory. The module directory structure is now complete and looks like this:
现在开始在“views”这个子文件夹里新建一个文件"view_form_field_handler_title_edit.inc"。完成后，模块目录结构现在看起来是这样的：

Next, edit the .info file and add the following the line.
接下来编辑.info文件，添加下面这行代码。

files[] = views/view_form_field_handler_title_edit.inc

This line tells Drupal where to find and auto-load our field handler whenever Views needs it.
这行代码告诉Drupal，当views需要时哪里可以自动加载我们的字段处理程序。

This is the basic class definition for your field handler. It extends "views_handler_field" and adds constructor and query methods to make sure the node id and title values are loaded into the view.
这是你的字段处理程序基本的类的定义。它继承自"views_handler_field"类并添加了构造函数和查询方法，以确保node id和标题被加载进view里。

Now, add the following "render" method to the class...this is when a little magic happens.现在添加如下输出方法

The render method returns the html (or other markup) to display for the field. To output a Views' managed form field, you render an HTML comment in the form in this format:
输出方法返回的HTML(或其他标记)是用来显示字段的。为了输出views管理的表单字段，你需要按照如下格式输出HTML的注释:<!--form-item-FIELD_ID--ROW_INDEX-->
This syntax mirrors the form array structure you'll use to provide replacement form fields views. When Views' sees that your field handler renders a comment like above, it will initialize and wrap a form around the view then call your handlers "views_form" method
这段语法表示了表单的数组结构，你将会使用这个结构给views的表单字段提供可替换的字符。当views看到你的字段处理程序输出如上注释，它会初始化并用一个表单的内容包裹在这段注释外面，然后调用你的处理函数的 "views_form" 这个方法。

The "views_form" method allows you to alter the form created by Views. Add your field replacements by creating a container element with an index that matches the field id ($this->options['id']). Then iterate over the view result and add a form field element to the container for every row in the view, using the row index as the element key in the container. Views matches this form array structure to the corresponding HTML comment to insert the field in the rendered View. In other words:
"views_form"方法允许你去修改views创建的表单。添加你的字段，用一个带有索引并与字段ID ($this->options['id'])匹配的容器元素代替。然后，遍历view的结果并添加一个表单元素到容器中的每一行，使用行的索引当做容器的键名。Views匹配这个表单的数组结构到对应的HTML注释中，在输出好的view中插入字段。换句话说：

<!--form-item-FIELD_ID--ROW_INDEX-->
is replaced by:可以被替换为

<?php
$form[FIELD_ID][ROW_INDEX];
?>

The above "views_form" method adds a textfield to every row pre-filled with the node title. I've specified a "element_validate" handler to the field because Views doesn't wire up a form-wide validate handler.
上述的"views_form"方法添加了文本字段到每行中，预填了node标题的值。我对这个字段指定了"element_validate"处理程序，因为views不使用平常广泛使用的表单校验处理程序。

Create your element validation callback OUTSIDE the class but in the same .inc file so that it is available in the global context but is only loaded with the field handler:
新建你的元素校验处理程序，在类的外面但在.inc文件的里面。这样它才能再全局上下文中可以使用但只和字段处理程序一起加载。

The "views_form_submit" method works much like any Form API submit callback. In the case above, you iterate over the view result to identify submitted changes, then iterate over the changes to update the corresponding nodes.
"views_form_submit"方法和Form API 的提交回调函数工作原理类似。在上述例子中，你遍历了view的结果用来区分提交后的改动的内容，然后遍历改动的内容去更新相应的node。

A note about the use of "$this->aliases": this is one way that Views ensures that different field handlers don't collide. Think about it, the Views UI allows you to add any number of fields called "title", any other form field handler, or even another instance of this handler. To allow this, Views indexes the result objects with unique field aliases, so you should use the syntax "$row->{$this->aliases['title']}" when grabbing results to make sure you get the right "title".
关于使用"$this->aliases"一个值得注意的地方，这是一个确保不同的字段处理函数不会冲突的地方。设想一下，View的界面允许你添加任意数量叫“标题”的字段，还有任何其他的表单处理程序，甚至当前处理函数的其他实例。为了允许这么做，views使用唯一的字段别名给结果对象的编配了唯一索引。所以，当你获取结果时，应该使用语法如"$row->{$this->aliases['title']}" 去保证你获得正确的那个“标题”字段。

So that's it. You've now created a View form. There are plenty of places to you could take this. You could easily substitute multiple form elements by adding additional fields to your container. You could use the Form API "#ajax" element to handle form submissions without a page refresh. You could include a submit button on every row and only allow one row to be updated at a time.
就这样了，你现在已经创建了一个view的表单。还有很多地方你需要使用这个功能。你可以通过添加额外的字段到容器中简单的替换多个表单元素。你可以使用Form API 的'#ajax'元素去无刷新处理表单提交.你可以在任意行或只有一行引入一个提交按钮去同时更新.