public function preDispatch() { parent::preDispatch(); $t = microtime(true); if (!isset($this->_form)) { if (isset($this->_formName)) { $this->_form = new $this->_formName(); } else { $this->_form = new Kwf_Form(); } } foreach ($this->_fields as $k => $field) { if (!isset($field['type'])) { throw new Kwf_Exception("no type for field no {$k} specified"); } $cls = 'Kwf_Form_Field_' . $field['type']; if (!class_exists($cls)) { throw new Kwf_Exception("Invalid type: Form-Field-Class {$cls} does not exist."); } $fieldObject = new $cls(); unset($field['type']); foreach ($field as $propName => $propValue) { $fieldObject->setProperty($propName, $propValue); } $this->_form->fields[] = $fieldObject; } if (!$this->_form->getModel()) { if (isset($this->_table)) { $this->_form->setTable($this->_table); } else { if (isset($this->_tableName)) { $this->_form->setTable(new $this->_tableName()); } else { if (isset($this->_modelName)) { $this->_form->setModel(new $this->_modelName()); } else { if (isset($this->_model)) { if (is_string($this->_model)) { $this->_form->setModel(Kwf_Model_Abstract::getInstance($this->_model)); } else { $this->_form->setModel($this->_model); } } } } } } $this->_initFields(); $this->_form->initFields(); $this->_form->trlStaticExecute(); if (!$this->_form->fields->first() instanceof Kwf_Form_Container_Tabs) { $this->_form->setBodyStyle('padding: 10px;'); } if (!$this->_form->getId()) { if (is_array($this->_form->getPrimaryKey())) { foreach ($this->_form->getPrimaryKey() as $key) { $id[$key] = $this->_getParam($key); } $this->_form->setId($id); } else { $this->_form->setId($this->_getParam($this->_form->getPrimaryKey())); } } Kwf_Benchmark::subCheckpoint('init form', microtime(true) - $t); }