---
title: "form component"
author: "xu_wccq"
date: "2008-12-16T22:34:44Z"
tags: ["C", "C#", "C++", "EXT", "F#"]
slug: "form-component"
draft: false
lastmod: "2008-12-16T22:34:44Z"
id: 295624
url: "https://hooney.iteye.com/blog/295624"
---

我们在form loadData完成之后它便可以把值设置到相应的字段去. 通过formpanel.form.findField(fieldName) 找到对应的Ext的component . 可以看formfindField()的实现

```

这是在 Ext.form.BaseForm 里面实现的.
findField : function (id) {
    var field = this.items.get(id);
    if (!field) {
        this.items.each(function (f) {if (f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)) {field = f;return false;}});
    }
    return field || null;
}
其中 this.items.each 这里的items 是在构造formpanel的时候,
  利用
onAdd : function(ct, c) {  // Ext.form.formPanel  (Form.js)
// 判断此component是不是formField，是否添加到this.form列表里面，待formpanel 的setValues 时把值设置到对应的component里面。
		if (c.isFormField) {
			this.form.add(c);
		}
},


```