diff --git a/src/CustomForm/ManageCustomForm.php b/src/CustomForm/ManageCustomForm.php index fe04112..242d09b 100644 --- a/src/CustomForm/ManageCustomForm.php +++ b/src/CustomForm/ManageCustomForm.php @@ -714,8 +714,8 @@ public function AddForm(): void $this->smcFunc['db_insert']( '', '{db_prefix}cf_forms', - ['id_board' => 'int'], - ['0'], + ['id_board' => 'int', 'title' => 'string', 'icon' => 'string', 'output' => 'string', 'subject' => 'string', 'form_exit' => 'string', 'template_function' => 'string', 'output_type' => 'string'], + ['0', '', '', '', '', '', '', ''], ['id_form'] ); $form_id = $this->smcFunc['db_insert_id']('{db_prefix}cf_forms', 'id_form'); @@ -924,8 +924,8 @@ public function AddField(int $form_id): void $this->smcFunc['db_insert']( '', '{db_prefix}cf_fields', - ['id_form' => 'int'], - [$form_id], + ['id_form' => 'int', 'title' => 'string', 'type' => 'string', 'text' => 'string', 'type_vars' => 'string'], + [$form_id, '', '', '', ''], ['id_field'] ); $field_id = $this->smcFunc['db_insert_id']('{db_prefix}cf_fields', 'id_field'); diff --git a/src/install.php b/src/install.php index 6e13a08..6f638d1 100644 --- a/src/install.php +++ b/src/install.php @@ -34,36 +34,30 @@ 'name' => 'title', 'type' => 'varchar', 'size' => 150, - 'null' => true, ], [ 'name' => 'subject', 'type' => 'varchar', 'size' => 150, - 'null' => true, ], [ 'name' => 'icon', 'type' => 'varchar', 'size' => 150, - 'null' => true, ], [ 'name' => 'form_exit', 'type' => 'varchar', 'size' => 150, - 'null' => true, ], [ 'name' => 'template_function', 'type' => 'varchar', 'size' => 150, - 'null' => true, ], [ 'name' => 'output', 'type' => 'text', - 'null' => true, ], ]; $indexes = [ @@ -90,24 +84,20 @@ 'name' => 'title', 'type' => 'varchar', 'size' => 150, - 'null' => true, ], [ 'name' => 'text', 'type' => 'varchar', 'size' => 4096, - 'null' => true, ], [ 'name' => 'type', 'type' => 'varchar', 'size' => 150, - 'null' => true, ], [ 'name' => 'type_vars', 'type' => 'text', - 'null' => true, ], ]; $indexes = [ diff --git a/src/upgrade.php b/src/upgrade.php index c12e28e..79b1db8 100644 --- a/src/upgrade.php +++ b/src/upgrade.php @@ -37,3 +37,17 @@ ); $smcFunc['db_free_result']($request); + +$smcFunc['db_query']('', ' + UPDATE {db_prefix}cf_forms + SET icon = CASE WHEN icon IS NULL THEN \'\' ELSE icon END, + title = CASE WHEN title IS NULL THEN \'\' ELSE title END, output = CASE WHEN output IS NULL THEN \'\' ELSE output END, + subject = CASE WHEN subject IS NULL THEN \'\' ELSE subject END, + form_exit = CASE WHEN form_exit IS NULL THEN \'\' ELSE form_exit END, + template_function = CASE WHEN template_function IS NULL THEN \'\' ELSE template_function END, + output_type = CASE WHEN output_type IS NULL THEN \'\' ELSE output_type END'); + +$smcFunc['db_query']('', ' + UPDATE {db_prefix}cf_fields + SET title = CASE WHEN title IS NULL THEN \'\' ELSE title END, text = CASE WHEN text IS NULL THEN \'\' ELSE text END, + type = CASE WHEN type IS NULL THEN \'\' ELSE type END, type_vars = CASE WHEN type_vars IS NULL THEN \'\' ELSE type_vars END');