fix: don't submit data of removed fields
This commit is contained in:
@@ -47,4 +47,8 @@ final class Constants
|
|||||||
public const STATUS_AVAILABLE = 'Frei';
|
public const STATUS_AVAILABLE = 'Frei';
|
||||||
public const STATUS_BLOCKED = 'Buchungsstop';
|
public const STATUS_BLOCKED = 'Buchungsstop';
|
||||||
public const STATUS_ON_REQUEST = 'Anfrage';
|
public const STATUS_ON_REQUEST = 'Anfrage';
|
||||||
|
|
||||||
|
// Payment methods
|
||||||
|
public const PAYMENT_METHOD_TRANSFER = 'transfer';
|
||||||
|
public const PAYMENT_METHOD_DEBIT = 'debit';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,26 +176,7 @@ class BookingParticipantType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
private function removeExcludedFields(FormInterface $form, BookingDtoInterface $bookingDto, int $participantIndex, array $formData = []): void
|
private function removeExcludedFields(FormInterface $form, BookingDtoInterface $bookingDto, int $participantIndex, array $formData = []): void
|
||||||
{
|
{
|
||||||
$dynamicFields = [
|
foreach (ParticipantDto::DYNAMIC_FIELDS as $fieldName) {
|
||||||
'assignedRoomId',
|
|
||||||
'remarksRoom',
|
|
||||||
'courses',
|
|
||||||
'additionalServices',
|
|
||||||
'board',
|
|
||||||
'rentals',
|
|
||||||
'rentalInsurance',
|
|
||||||
'skiPass',
|
|
||||||
'transportationOutbound',
|
|
||||||
'transportationInbound',
|
|
||||||
'pickupOutbound',
|
|
||||||
'pickupInbound',
|
|
||||||
'parking',
|
|
||||||
'licensePlate',
|
|
||||||
'bulkInsuranceBooking',
|
|
||||||
'insurance',
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($dynamicFields as $fieldName) {
|
|
||||||
if ($form->has($fieldName) && !$this->fieldStateProvider->shouldIncludeField($fieldName, $bookingDto, $participantIndex, $formData)) {
|
if ($form->has($fieldName) && !$this->fieldStateProvider->shouldIncludeField($fieldName, $bookingDto, $participantIndex, $formData)) {
|
||||||
$form->remove($fieldName);
|
$form->remove($fieldName);
|
||||||
}
|
}
|
||||||
@@ -224,12 +205,7 @@ class BookingParticipantType extends AbstractType
|
|||||||
$this->addBaseFields($form, $bookingDto, $participantIndex);
|
$this->addBaseFields($form, $bookingDto, $participantIndex);
|
||||||
|
|
||||||
// Rebuild dynamic fields
|
// Rebuild dynamic fields
|
||||||
$dynamicFields = [
|
foreach (ParticipantDto::DYNAMIC_FIELDS as $fieldName) {
|
||||||
'assignedRoomId', 'remarksRoom', 'courses', 'additionalServices', 'board', 'rentals', 'rentalInsurance',
|
|
||||||
'skiPass', 'transportationOutbound', 'transportationInbound', 'pickupOutbound', 'pickupInbound', 'parking',
|
|
||||||
'licensePlate', 'bulkInsuranceBooking', 'insurance',
|
|
||||||
];
|
|
||||||
foreach ($dynamicFields as $fieldName) {
|
|
||||||
if ($form->has($fieldName)) {
|
if ($form->has($fieldName)) {
|
||||||
$form->remove($fieldName);
|
$form->remove($fieldName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,7 +294,9 @@ class ParticipantFieldHandlerRegistry
|
|||||||
{
|
{
|
||||||
// Sync fields for all registered handlers
|
// Sync fields for all registered handlers
|
||||||
foreach ($this->handlers as $fieldName => $handler) {
|
foreach ($this->handlers as $fieldName => $handler) {
|
||||||
if (property_exists($participant, $fieldName)) {
|
// Only sync fields that were in the original submission
|
||||||
|
// This prevents adding extra fields that would cause validation errors
|
||||||
|
if (property_exists($participant, $fieldName) && array_key_exists($fieldName, $participantData)) {
|
||||||
$dtoValue = $participant->{$fieldName};
|
$dtoValue = $participant->{$fieldName};
|
||||||
$participantData[$fieldName] = $this->convertDtoValueToSubmittedFormat($dtoValue);
|
$participantData[$fieldName] = $this->convertDtoValueToSubmittedFormat($dtoValue);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user