2010-05-21 35 views
5

我有一个生成的表单面板脚本动态生成字段:EXTJS - 位于FormPanel

var form = new Ext.FormPanel({ 
    id: 'form-exploit-zombie-' + zombie_ip, 
    formId: 'form-exploit-zombie-' + zombie_ip, 
    border: false, 
    labelWidth: 75, 
    formBind: true, 
    defaultType: 'textfield', 
    url: '/ui/modules/exploit/new', 
    autoHeight: true, 
    buttons: [{ 
     text: 'Execute exploit', 
     handler: function() { 
      var form = Ext.getCmp('form-exploit-zombie-' + zombie_ip); 

      form.getForm().submit({ 
       waitMsg: 'Running exploit ...', 
       success: function() { 
        Ext.beef.msg('Yeh!', 'Exploit sent to the zombie.') 
       }, 
       failure: function() { 
        Ext.beef.msg('Ehhh!', 'An error occured while trying to send the exploit.') 
       } 
      }); 
     } 
    }] 
}); 

相同的脚本,然后检索从我的服务器json文件,它定义了多少输入字段的形式应包含。该脚本然后将这些字段的形式:

Ext.each(inputs, function(input) { 
    var input_name; 
    var input_type = 'TextField'; 
    var input_definition = new Array(); 

    if(typeof input == 'string') { 
     input_name = input; 
     var field = new Ext.form.TextField({ 
       id: 'form-zombie-'+zombie_ip+'-field-'+input_name, 
       fieldLabel: input_name, 
       name: 'txt_'+input_name, 
       width: 175, 
       allowBlank:false 
      }); 
     form.add(field); 
    } 
    else if(typeof input == 'object') { 
     //input_name = array_key(input); 

     for(definition in input) { 
      if(typeof definition == 'string') { 

      } 
     } 
    } else { 
     return; 
    } 
}); 

最后,形式添加到相应的面板在我的界面:

panel.add(form); 
panel.doLayout(); 

我的问题是:当我提交的表单点击按钮,发送到我的服务器的http请求不包含添加到表单的字段。换句话说,我不会将这些字段发布到服务器上。

任何人都知道我为什么以及如何解决这个问题?

回答

9

您的问题,得到的是在这里:

id: 'form-exploit-zombie-'+zombie_ip, 
formId: 'form-exploit-zombie-'+zombie_ip, 

你在做什么是你设置的id属性窗体面板和窗体(窗体标签)的id属性设置为相同的值。这意味着你有两个具有相同ID的元素,这是错误的。

就删除此行

formId: 'form-exploit-zombie-'+zombie_ip, 

,你应该罚款。

+0

我爱你。谢谢。 – Benjamin 2010-05-21 09:19:16

+0

@Benjamin:没问题。 – 2010-05-21 10:04:35

0

您是否检查了表单值的HTTP请求参数?

如果你的服务器端是在PHP中,你通过传递任何字段名称从响应中得到什么?例如,如果你输入的名字之一是“XYZ”你是什么

$_POST[ 'txt_xyz' ] 
+0

是的,我没有检查。 – Benjamin 2010-05-21 07:36:10

相关问题