wip: courses
This commit is contained in:
@@ -163,7 +163,7 @@ class BookingCreateParticipantType extends AbstractType
|
||||
*/
|
||||
private function addDynamicFields(FormInterface $form, BookingDtoInterface $bookingDto, int $participantIndex): void
|
||||
{
|
||||
$dynamicFields = ['assignedRoomId']; // List of fields that need dynamic configuration
|
||||
$dynamicFields = ['assignedRoomId', 'courses']; // List of fields that need dynamic configuration
|
||||
|
||||
foreach ($dynamicFields as $fieldName) {
|
||||
if ($this->fieldOptionsProvider->hasFieldOptions($fieldName)) {
|
||||
|
||||
@@ -17,7 +17,8 @@ class BookingEditType extends AbstractType
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ParticipantFieldHandlerRegistry $participantFieldHandlerRegistry,
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
|
||||
@@ -78,7 +78,7 @@ abstract class AbstractFieldOptionsProvider implements FieldOptionsProviderInter
|
||||
* Symfony form field options.
|
||||
*
|
||||
* Example implementation:
|
||||
*
|
||||
*
|
||||
* protected function registerFieldOptionProviders(): void
|
||||
* {
|
||||
* $this->fieldOptionProviders['fieldName'] = fn($bookingDto, $participantIndex) => [
|
||||
@@ -88,4 +88,4 @@ abstract class AbstractFieldOptionsProvider implements FieldOptionsProviderInter
|
||||
* }
|
||||
*/
|
||||
abstract protected function registerFieldOptionProviders(): void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Service;
|
||||
|
||||
use App\BusProNet\Constants;
|
||||
use App\BusProNet\Model\Service;
|
||||
use App\Form\Model\BookingCreateDto;
|
||||
use App\Form\Model\BookingDtoInterface;
|
||||
use App\Form\Service\Abstract\AbstractFieldOptionsProvider;
|
||||
@@ -84,6 +86,23 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
|
||||
: null,
|
||||
];
|
||||
|
||||
// Courses field provider - provides available courses from travel data
|
||||
$this->fieldOptionProviders['courses'] = fn (BookingDtoInterface $bookingDto) => [
|
||||
'label' => 'Kurse',
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'required' => false,
|
||||
'choices' => array_reduce(
|
||||
$bookingDto->travel->getAdditionalServicesByGroup(Constants::TOKEN_COURSES),
|
||||
function (array $choices, Service $service) {
|
||||
$choices[$service->label] = $service->id;
|
||||
|
||||
return $choices;
|
||||
},
|
||||
[]
|
||||
),
|
||||
];
|
||||
|
||||
// Future field providers would be added here, for example:
|
||||
//
|
||||
// $this->fieldOptionProviders['mealPreference'] = fn($bookingDto, $participantIndex) => [
|
||||
|
||||
Reference in New Issue
Block a user