diff --git a/go-form-plugin/database-schema.sql b/go-form-plugin/database-schema.sql index 8cb0cdc..8abd915 100644 --- a/go-form-plugin/database-schema.sql +++ b/go-form-plugin/database-schema.sql @@ -20,7 +20,8 @@ CREATE TABLE wp_go_form_entries ( 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) + INDEX (form_id), + INDEX (egd_number) ); -- ========== Custom Fields Tables ========== @@ -29,10 +30,11 @@ 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_type enum('select','text','checkbox', 'email', 'textarea') NOT NULL DEFAULT 'text', field_options text, is_public tinyint(1) NOT NULL DEFAULT 0, is_required tinyint(1) NOT NULL DEFAULT 0, + is_full_width 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) diff --git a/go-form-plugin/go-form-plugin.php b/go-form-plugin/go-form-plugin.php index 5a9d9b7..6d5d556 100644 --- a/go-form-plugin/go-form-plugin.php +++ b/go-form-plugin/go-form-plugin.php @@ -34,17 +34,19 @@ function go_form_activate() created_at date DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY (id), FOREIGN KEY (form_id) REFERENCES $forms(id) ON DELETE CASCADE, - INDEX (form_id) + INDEX (form_id), + INDEX (egd_number) ) $charset;"); dbDelta("CREATE TABLE $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_type enum('select','text','checkbox', 'email', 'textarea') NOT NULL DEFAULT 'text', field_options text, is_public tinyint(1) NOT NULL DEFAULT 0, is_required tinyint(1) NOT NULL DEFAULT 0, + is_full_width tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (id), FOREIGN KEY (form_id) REFERENCES $forms(id) ON DELETE CASCADE, INDEX (form_id) @@ -352,6 +354,7 @@ function go_form_create_custom_field() $field_options = isset($_POST['field_options']) ? sanitize_textarea_field($_POST['field_options']) : ''; $is_public = isset($_POST['is_public']) ? 1 : 0; $is_required = isset($_POST['is_required']) ? 1 : 0; + $is_full_width = isset($_POST['is_full_width']) ? 1 : 0; $wpdb->insert("{$wpdb->prefix}go_form_custom_fields", [ 'form_id' => $form_id, @@ -359,7 +362,8 @@ function go_form_create_custom_field() 'field_type' => $field_type, 'field_options' => $field_options, 'is_public' => $is_public, - 'is_required' => $is_required + 'is_required' => $is_required, + 'is_full_width' => $is_full_width ]); } $redirect_url = add_query_arg(array('page' => 'go-form-settings', 'form_id' => $_POST['form_id'], 'created_field' => 1), admin_url('admin.php')); @@ -379,13 +383,15 @@ function go_form_update_custom_field() $field_options = isset($_POST['field_options']) ? sanitize_textarea_field($_POST['field_options']) : ''; $is_public = isset($_POST['is_public']) ? 1 : 0; $is_required = isset($_POST['is_required']) ? 1 : 0; + $is_full_width = isset($_POST['is_full_width']) ? 1 : 0; $wpdb->update("{$wpdb->prefix}go_form_custom_fields", [ 'field_name' => $field_name, 'field_type' => $field_type, 'field_options' => $field_options, 'is_public' => $is_public, - 'is_required' => $is_required + 'is_required' => $is_required, + 'is_full_width' => $is_full_width ], ['id' => $field_id]); } $redirect_url = add_query_arg(array('page' => 'go-form-settings', 'form_id' => $_POST['form_id'], 'updated_field' => 1), admin_url('admin.php')); @@ -397,9 +403,9 @@ add_action('admin_post_go_form_update_custom_field', 'go_form_update_custom_fiel function go_form_delete_custom_field() { go_form_admin_action('delete_custom_field'); - if (isset($_POST['field_id'])) { + if (isset($_POST['value_one'])) { global $wpdb; - $field_id = intval($_POST['field_id']); + $field_id = intval($_POST['value_one']); $field = go_form_get_custom_field_by_id($field_id); $form_id = $field ? $field->form_id : 0; $wpdb->delete("{$wpdb->prefix}go_form_custom_fields", ['id' => $field_id]); diff --git a/go-form-plugin/templates/form-shortcode.php b/go-form-plugin/templates/form-shortcode.php index 199ac4e..ecb0322 100644 --- a/go-form-plugin/templates/form-shortcode.php +++ b/go-form-plugin/templates/form-shortcode.php @@ -102,7 +102,19 @@ is_full_width) { + $full_width_fields[] = $field; + } else { + $grid_fields[] = $field; + } + } + + // Render grid fields + foreach ($grid_fields as $field): $field_id = 'custom_field_' . $field->id; echo '
* Required fields
diff --git a/go-form-plugin/templates/settings-page.php b/go-form-plugin/templates/settings-page.php index ded7c2b..f5330c4 100644 --- a/go-form-plugin/templates/settings-page.php +++ b/go-form-plugin/templates/settings-page.php @@ -41,10 +41,10 @@ if (isset($_GET['error']) && $_GET['error'] == 'egd_update_failed') echo '| Field Name | Type | Public | Required | Actions | |
|---|---|---|---|---|---|
| Field Name | Type | Public | Required | Full Width | Actions |
| ' . esc_html($field->field_name) . ' | '; echo '' . esc_html($field->field_type) . ' | '; echo '' . ($field->is_public ? 'Yes' : 'No') . ' | '; echo '' . ($field->is_required ? 'Yes' : 'No') . ' | '; + echo '' . ($field->is_full_width ? 'Yes' : 'No') . ' | '; echo ''; // Edit button (toggle to show edit form) echo 'Edit '; @@ -119,11 +122,13 @@ if (isset($_GET['error']) && $_GET['error'] == 'egd_update_failed') echo ''; echo ''; echo ''; + echo ''; echo ''; echo ' |
| e.g., Option 1,Option 2,Option 3 | |||||
| is_public, 1, false) . '> Show on public form | |||||
| is_required, 1, false) . '> Required field | |||||
| is_full_width, 1, false) . '> Display on full width (outside grid) |