private function showTheEditField(FBField $field)
 {
     static $t;
     if (!$t) {
         $t = new FBTemplatizer('field_edit.phtml');
     }
     $t->clear();
     $t->set('FIELD_ID', $field->getId());
     $t->set('FIELD_NAME', htmlentities($field->getName(), ENT_QUOTES, get_option('blog_charset')));
     $t->set('FIELD_VALUE', htmlentities($field->getValue(), ENT_QUOTES, get_option('blog_charset')));
     $t->set('FIELD_LABEL', htmlentities($field->getLabel(), ENT_QUOTES, get_option('blog_charset')));
     $t->set('FIELD_ERROR', htmlentities($field->getError(), ENT_QUOTES, get_option('blog_charset')));
     $t->set('FIELD_HELP', htmlentities($field->getHelp(), ENT_QUOTES, get_option('blog_charset')));
     $all_field_types = formbuilder_get_field_types();
     $html = '';
     $help = '';
     foreach ($all_field_types as $key => $value) {
         if ($key == $field->getType()) {
             $selected = "selected = 'selected'";
         } else {
             $selected = "";
         }
         $html .= "<option value='{$key}' {$selected}>{$key}</option>";
         $help .= "{$key}: {$value}\\n";
     }
     $t->set('FIELD_TYPE_SELECT', $html);
     $t->set('FIELD_TYPE_HELP', htmlentities($help, ENT_QUOTES, get_option('blog_charset')));
     $all_required_types = formbuilder_get_required_types();
     $html = '';
     $help = '';
     foreach ($all_required_types as $key => $value) {
         if ($key == $field->getRequired()) {
             $selected = "selected = 'selected'";
         } else {
             $selected = "";
         }
         $html .= "<option value='{$key}' {$selected}>{$key}</option>";
         $help .= "{$key}: {$value}\\n";
     }
     $t->set('FIELD_REQUIRED_SELECT', $html);
     $t->set('FIELD_REQUIRED_HELP', htmlentities($help, ENT_QUOTES, get_option('blog_charset')));
     return $t->parse();
 }
 private function loadFields()
 {
     $this->lazyLoadForm();
     global $wpdb;
     if ($this->id !== false) {
         $sql = "SELECT * FROM " . FORMBUILDER_TABLE_FIELDS . " WHERE form_id = '{$this->id}' ORDER BY display_order;";
         $results = $wpdb->get_results($sql, ARRAY_A);
         if (count($results) > 0) {
             $this->fields = array();
             foreach ($results as $fieldArray) {
                 $fieldID = $fieldArray['id'];
                 $field = new FBField();
                 $field->loadFromArray($fieldID, $fieldArray);
                 $this->addfield($field);
             }
         }
     } else {
         throw new Exception("No form ID given.");
     }
 }
 static function create($form_id)
 {
     global $wpdb;
     $sql = "INSERT INTO " . FORMBUILDER_TABLE_FIELDS . " (`form_id`) VALUES ('{$form_id}');";
     $result = $wpdb->query($sql);
     $insert_id = $wpdb->insert_id;
     $field = new FBField();
     $field->loadFromID($insert_id);
     return $field;
 }