fix: don't submit data of removed fields
This commit is contained in:
@@ -176,26 +176,7 @@ class BookingParticipantType extends AbstractType
|
||||
*/
|
||||
private function removeExcludedFields(FormInterface $form, BookingDtoInterface $bookingDto, int $participantIndex, array $formData = []): void
|
||||
{
|
||||
$dynamicFields = [
|
||||
'assignedRoomId',
|
||||
'remarksRoom',
|
||||
'courses',
|
||||
'additionalServices',
|
||||
'board',
|
||||
'rentals',
|
||||
'rentalInsurance',
|
||||
'skiPass',
|
||||
'transportationOutbound',
|
||||
'transportationInbound',
|
||||
'pickupOutbound',
|
||||
'pickupInbound',
|
||||
'parking',
|
||||
'licensePlate',
|
||||
'bulkInsuranceBooking',
|
||||
'insurance',
|
||||
];
|
||||
|
||||
foreach ($dynamicFields as $fieldName) {
|
||||
foreach (ParticipantDto::DYNAMIC_FIELDS as $fieldName) {
|
||||
if ($form->has($fieldName) && !$this->fieldStateProvider->shouldIncludeField($fieldName, $bookingDto, $participantIndex, $formData)) {
|
||||
$form->remove($fieldName);
|
||||
}
|
||||
@@ -224,12 +205,7 @@ class BookingParticipantType extends AbstractType
|
||||
$this->addBaseFields($form, $bookingDto, $participantIndex);
|
||||
|
||||
// Rebuild dynamic fields
|
||||
$dynamicFields = [
|
||||
'assignedRoomId', 'remarksRoom', 'courses', 'additionalServices', 'board', 'rentals', 'rentalInsurance',
|
||||
'skiPass', 'transportationOutbound', 'transportationInbound', 'pickupOutbound', 'pickupInbound', 'parking',
|
||||
'licensePlate', 'bulkInsuranceBooking', 'insurance',
|
||||
];
|
||||
foreach ($dynamicFields as $fieldName) {
|
||||
foreach (ParticipantDto::DYNAMIC_FIELDS as $fieldName) {
|
||||
if ($form->has($fieldName)) {
|
||||
$form->remove($fieldName);
|
||||
}
|
||||
|
||||
@@ -294,7 +294,9 @@ class ParticipantFieldHandlerRegistry
|
||||
{
|
||||
// Sync fields for all registered handlers
|
||||
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};
|
||||
$participantData[$fieldName] = $this->convertDtoValueToSubmittedFormat($dtoValue);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user