예제 #1
0
파일: creating.php 프로젝트: klan1/k1.lib
 /**
  * Put an input object of certain type depending of the MySQL Table Feld Type on each data row[n]
  * @param Int $row_to_apply
  */
 public function insert_inputs_on_data_row($create_labels_tags_on_headers = TRUE)
 {
     // Row to apply is constant coz this is CREATE or EDIT and there is allways just 1 set of data to manipulate.
     $row_to_apply = 1;
     /**
      * VALUES
      */
     foreach ($this->db_table_data_filtered[$row_to_apply] as $field => $value) {
         /**
          * Switch on DB field specific TYPES
          */
         switch ($this->db_table->get_field_config($field, 'type')) {
             case 'enum':
                 $input_tag = input_helper::enum_type($this, $field);
                 break;
             case 'text':
                 switch ($this->db_table->get_field_config($field, 'validation')) {
                     case "html":
                         $input_tag = input_helper::text_type($this, $field);
                         break;
                     default:
                         $input_tag = input_helper::text_type($this, $field, FALSE);
                         break;
                 }
                 break;
             default:
                 /**
                  * Switch on K1lib DB Table Config VALIDATION TYPES
                  */
                 switch ($this->db_table->get_field_config($field, 'validation')) {
                     case "file-upload":
                         $input_tag = input_helper::file_upload($this, $field);
                         break;
                     case "password":
                         if (empty($value)) {
                             $input_tag = input_helper::password_type($this, $field, $this->object_state);
                         } else {
                             $input_tag = input_helper::password_type($this, $field, $this->object_state);
                         }
                         break;
                     default:
                         $input_tag = input_helper::default_type($this, $field);
                         break;
                 }
                 break;
         }
         /**
          * LABELS 
          */
         if ($create_labels_tags_on_headers) {
             $label_tag = new \k1lib\html\label($this->db_table_data_filtered[0][$field], $this->encrypt_field_name($field));
             if ($this->db_table->get_field_config($field, 'required') === TRUE) {
                 $label_tag->set_value(" *", TRUE);
             }
             if (isset($this->post_validation_errors[$field])) {
                 $label_tag->set_attrib("class", "is-invalid-label");
             }
             $this->db_table_data_filtered[0][$field] = $label_tag;
         }
         /**
          * ERROR TESTING
          */
         if (isset($this->post_validation_errors[$field])) {
             $div_error = new \k1lib\html\foundation\grid_row(2);
             $div_input = $div_error->col(1)->large(12);
             $div_message = $div_error->col(2)->large(12)->end();
             $span_error = $div_message->append_span("clearfix form-error is-visible");
             $span_error->set_value($this->post_validation_errors[$field]);
             $input_tag->append_to($div_input);
             $input_tag->set_attrib("class", "is-invalid-input", TRUE);
             $div_error->link_value_obj($input_tag);
         }
         /**
          * END ERROR TESTING
          */
         if ($this->db_table->get_field_config($field, 'required') === TRUE) {
             if ($this->enable_foundation_form_check) {
                 $input_tag->set_attrib("required", TRUE);
             }
         }
         $input_tag->set_attrib("k1lib-data-type", $this->db_table->get_field_config($field, 'validation'));
         $input_tag->set_attrib("id", $this->encrypt_field_name($field));
         if (isset($div_error)) {
             $this->apply_html_tag_on_field_filter($div_error, $field);
             unset($div_error);
         } else {
             $this->apply_html_tag_on_field_filter($input_tag, $field);
         }
         unset($input_tag);
     }
 }