Start work on custom fields

This commit is contained in:
2026-05-09 00:43:23 +02:00
parent 04d625110d
commit 8b54aff9ac
3 changed files with 53 additions and 2 deletions

View File

@@ -0,0 +1,51 @@
-- ========== Original Plugin Tables ==========
CREATE TABLE wp_go_form_forms (
id int NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE wp_go_form_entries (
id int NOT NULL AUTO_INCREMENT,
form_id int DEFAULT 1,
first_name varchar(100) NOT NULL,
last_name varchar(100) NOT NULL,
country varchar(100) DEFAULT NULL,
club varchar(100) DEFAULT NULL,
rank tinyint(2) DEFAULT 0,
rating smallint(5) DEFAULT 0,
egd_number varchar(20) DEFAULT NULL,
created_at date DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (form_id) REFERENCES wp_go_form_forms(id) ON DELETE CASCADE,
INDEX (form_id)
);
-- ========== Custom Fields Tables ==========
CREATE TABLE wp_go_form_custom_fields (
id int NOT NULL AUTO_INCREMENT,
form_id int NOT NULL,
field_name varchar(100) NOT NULL,
field_type enum('select','text','checkbox', 'email') NOT NULL DEFAULT 'text',
field_options text,
is_public tinyint(1) NOT NULL DEFAULT 0,
is_required tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (id),
FOREIGN KEY (form_id) REFERENCES wp_go_form_forms(id) ON DELETE CASCADE,
INDEX (form_id)
);
CREATE TABLE wp_go_form_entry_custom_values (
id int NOT NULL AUTO_INCREMENT,
entry_id int NOT NULL,
field_id int NOT NULL,
value text,
PRIMARY KEY (id),
FOREIGN KEY (entry_id) REFERENCES wp_go_form_entries(id) ON DELETE CASCADE,
FOREIGN KEY (field_id) REFERENCES wp_go_form_custom_fields(id) ON DELETE CASCADE,
INDEX (entry_id),
INDEX (field_id)
);

View File

@@ -248,7 +248,7 @@ function action_button($action, $name, $confirm_massage, $value_one)
{ {
echo ' echo '
<form method="post" action="' . admin_url('admin-post.php') . '"> <form method="post" action="' . admin_url('admin-post.php') . '">
' . wp_nonce_field($action . '_action', $action . '_nonce', true, false) . ' ' . wp_nonce_field("{$action}_action", "{$action}_nonce", true, false) . '
<input type="hidden" name="action" value="' . $action . '"> <input type="hidden" name="action" value="' . $action . '">
<input type="hidden" name="value_one" value="' . $value_one . '"> <input type="hidden" name="value_one" value="' . $value_one . '">
<input type="submit" value="' . $name . '" class="button" onclick="return confirm(\'' . $confirm_massage . '\')"> <input type="submit" value="' . $name . '" class="button" onclick="return confirm(\'' . $confirm_massage . '\')">

View File

@@ -2,7 +2,7 @@
/** /**
* Plugin Name: Go Form Plugin * Plugin Name: Go Form Plugin
* Description: Form plugin for Go players * Description: Form plugin for Go players
* Version: 0.04 * Version: 0.05-WIP
* Author: Nikola Petrov * Author: Nikola Petrov
*/ */