private function _create_form() { // iterate over all widgets so that they can add their piece to the form foreach ($this->_schema->field_order as $name) { if (!isset($this->_schema->fields[$name])) { debug_add("Field {$name} is not present in \$this->_schema->fields (read from \$this->_schema->field_order)", MIDCOM_LOG_ERROR); continue; } $config = $this->_schema->fields[$name]; if (!$this->_is_widget_visible($name, $config)) { // Naturally we should skip invisible objects continue; } if (!$this->_load_widget($name)) { continue; } // Start the fieldsets if required $this->_start_fieldset($name, $config); if ($config['static_prepend'] !== null) { $static_name = "static_prepend_{$name}"; $this->form->addElement('static', $static_name, '', "<span class=\"static_prepend\">" . $this->_translate($config['static_prepend']) . "</span>"); } $this->widgets[$name]->set_form($this->form); $this->widgets[$name]->set_state($this->state); //Load custom QF rules, so that they can be used in widgets' add_element_to_form calls $this->_load_type_qfrules($name); $attributes = array('helptext' => $this->_translate($config['helptext'])); $this->widgets[$name]->add_elements_to_form($attributes); $this->_add_rules_and_filters($name, $config); $this->_load_field_default($name, $config); if ($config['static_append'] !== null) { $static_name = "__static_append_{$name}"; $this->form->addElement('static', $static_name, '', "<span class=\"static_append\">" . $this->_translate($config['static_append']) . "</span>"); } // End the fieldsets if required $this->_end_fieldset($name, $config); } // Set the collected defaults. $this->form->setDefaults($this->_defaults); // Close the fieldsets left open if ($this->_fieldsets > 0) { $this->_end_fieldset('', array('end_fieldset' => $this->_fieldsets)); } $this->_add_operation_buttons(); $this->_add_validation_rules(); $this->_add_filter_rules(); // Translate the required note $this->form->setRequiredNote('<span style="font-size:80%; color:#ff0000;">*</span>' . '<span style="font-size:80%;">' . $this->_l10n->get('denotes required field') . '</span>'); }