dongshou6041 2014-03-24 05:32
浏览 21

PURE CONFIGURATION在ZF2中意味着什么?

I was going through Form Creation in ZF2 and I read the following statement. " You can create the entire form, and input filter, using the Factory. This is particularly nice if you want to store your forms as pure configuration; you can simply pass the configuration to the factory and be done." Can anybody tell in detail what does PURE CONFIGURATION mean?

  • 写回答

1条回答 默认 最新

  • douji6735 2014-03-24 06:22
    关注

    It means that you're able to store your forms within any config file, e.g. module.config.php and then pass this configuration key into the form factory. This is similar what has been done in ZF1 often times, too.

    This whole process is done through the Zend\Form\Factory and if you check out the source code you'll see that you could pass it the following array to create a Form

    $someConfig = array(
      'form-key-name' => array(
        'fieldsets' => array(
            'fieldset_1' => array(
                'elements' => array(
                    'elem_x' => array(/** Single Form-Element Array*/)
                ),
                'fieldsets' => array(
                    'fs_y' => array(/** More Sub-Fieldset Array*/)
                ),
            )
        )
      )
    );
    

    Note that this example is quite incomplete (missing name => foo), hydrator configuration, inputFilter configuration, etc... but as it is this should give you a idea of what's meant by that statement.

    Using the above-mentioned configuration then you can pass it to the factory

    $factory = new \Zend\Form\Factory();
    $form    = $factory->createForm($someConfig['form-key-name']);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大