Add complete custom fields implementation and entry editing
- Add custom field CRUD in admin UI (create, read, update, delete) - Display custom fields on frontend form with proper field types - Save custom field values on form submission - Display custom field columns in entries table (admin and public) - Include custom field values in all export formats (CSV, PairGoTh, OpenGotha, McMahon) - Add Edit button and form for entries - Update entry handler to support editing with custom field values - Add success/error notices for all admin actions Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -10,16 +10,23 @@ $form_id = intval($_POST['value_one']);
|
||||
$form = go_form_get_form_by_id($form_id);
|
||||
$form_name = $form ? $form->name : 'Unknown Form';
|
||||
$entries = go_form_get_entries($form_id);
|
||||
$custom_fields = go_form_get_custom_fields($form_id);
|
||||
|
||||
header('Content-Type: text/csv; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="go-form-' . sanitize_title($form_name) . '-export.csv"');
|
||||
|
||||
$output = fopen('php://output', 'w');
|
||||
fputcsv($output, ['ID', 'First Name', 'Last Name', 'Country', 'Club', 'Rank', 'Rating', 'EGD Number', 'Date Added']);
|
||||
|
||||
// Build header row
|
||||
$header = ['ID', 'First Name', 'Last Name', 'Country', 'Club', 'Rank', 'Rating', 'EGD Number', 'Date Added'];
|
||||
foreach ($custom_fields as $field) {
|
||||
$header[] = $field->field_name;
|
||||
}
|
||||
fputcsv($output, $header);
|
||||
|
||||
foreach ($entries as $e) {
|
||||
global $ranks;
|
||||
fputcsv($output, [
|
||||
$row = [
|
||||
$e->id,
|
||||
$e->first_name,
|
||||
$e->last_name,
|
||||
@@ -29,7 +36,15 @@ foreach ($entries as $e) {
|
||||
$e->rating,
|
||||
$e->egd_number,
|
||||
$e->created_at
|
||||
]);
|
||||
];
|
||||
|
||||
// Add custom field values
|
||||
foreach ($custom_fields as $field) {
|
||||
$value = go_form_get_custom_value($e->id, $field->id);
|
||||
$row[] = $value;
|
||||
}
|
||||
|
||||
fputcsv($output, $row);
|
||||
}
|
||||
|
||||
fclose($output);
|
||||
Reference in New Issue
Block a user