Saving tribes as array

This commit is contained in:
Thomas Günther 2024-06-01 11:07:03 +02:00
parent 492d5a0028
commit c1d83d5536
3 changed files with 5 additions and 3 deletions

View File

@ -17,7 +17,7 @@ class CreateEvent {
$post_data['amount_default'] = str_replace(',', '.', $_POST['amount_default']); $post_data['amount_default'] = str_replace(',', '.', $_POST['amount_default']);
$post_data['amount_social'] = str_replace(',', '.', $_POST['amount_social']); $post_data['amount_social'] = str_replace(',', '.', $_POST['amount_social']);
$post_data['contributing_tribes'] = str_replace( PHP_EOL, ',', $post_data['contributing_tribes'] ); $post_data['contributing_tribes'] = serialize( explode(PHP_EOL, $post_data['contributing_tribes'] ) );
$new_event_id = $dbHandler->insertRows( $new_event_id = $dbHandler->insertRows(
'kompass_veranstaltungen_index', 'kompass_veranstaltungen_index',

View File

@ -17,7 +17,7 @@ class UpdateEvent {
$post_data['amount_default'] = str_replace(',', '.', $_POST['amount_default']); $post_data['amount_default'] = str_replace(',', '.', $_POST['amount_default']);
$post_data['amount_social'] = str_replace(',', '.', $_POST['amount_social']); $post_data['amount_social'] = str_replace(',', '.', $_POST['amount_social']);
$post_data['contributing_tribes'] = str_replace( PHP_EOL, ',', $post_data['contributing_tribes'] ); $post_data['contributing_tribes'] = serialize( explode(PHP_EOL, $post_data['contributing_tribes'] ) );
$dbHandler->updateRows( $dbHandler->updateRows(
'kompass_veranstaltungen_index', 'kompass_veranstaltungen_index',

View File

@ -5,12 +5,14 @@ use Bdp\Modules\EventParticipants\Models\Event as Event;
function kompass_print_event_edit_form(?int $event_id = null) function kompass_print_event_edit_form(?int $event_id = null)
{ {
$event = null; $event = null;
$tribes = '';
if (null === $event_id) { if (null === $event_id) {
$page = 'kompass-events&action=create-event'; $page = 'kompass-events&action=create-event';
} else { } else {
$page = 'kompass-events&action=update-event&event-id=' . $event_id; $page = 'kompass-events&action=update-event&event-id=' . $event_id;
$event = Event::loadById($event_id); $event = Event::loadById($event_id);
$tribes = implode(PHP_EOL, unserialize($event->contributing_tribes));
} }
$events_settings = BDP_LV_PLUGIN_SLUG . '-events-settings'; $events_settings = BDP_LV_PLUGIN_SLUG . '-events-settings';
@ -101,7 +103,7 @@ function kompass_print_event_edit_form(?int $event_id = null)
'kompass_print_textbox', 'kompass_print_textbox',
$events_settings, $events_settings,
'events_settings', 'events_settings',
['setting' => 'contributing_tribes', 'style' => 'width: 256px', 'lines' => 5, 'value' => str_replace(',', PHP_EOL, null !== $event ? $event->contributing_tribes : ''), 'appendix' => '<br />' . __('Please one line per row', BDP_LV_PLUGIN_SLUG)] ); ['setting' => 'contributing_tribes', 'style' => 'width: 256px', 'lines' => 5, 'value' => $tribes, 'appendix' => '<br />' . __('Please one line per row', BDP_LV_PLUGIN_SLUG)] );
do_settings_sections($events_settings); do_settings_sections($events_settings);
submit_button(); submit_button();