-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Closed as not planned
Closed as not planned
Copy link
Description
Symfony version(s) affected
7.4
Description
I’m experiencing issues with the new step-based forms. When using “nested” forms, events don’t seem to be triggered, and as a result it’s impossible to create fields dynamically (as described in the guide). See "How to reproduce".
In addition, even when trying to call addEventListener on FormFlowBuilderInterface to dynamically create a field... it is absolutely unclear how this can be done in order to add a dynamic field to a specific step (and, in that case, does the step need to exist as empty beforehand?).
class TestFlow extends AbstractFlowType
{
public function buildFormFlow(FormFlowBuilderInterface $builder, array $options): void
{
$builder
->addStep('step1', Step1Type::class, [
'inherit_data' => true,
])
;
$builder->addEventListener(FormEvents::PRE_SET_DATA, static function (FormEvent $event) {
// Now... what? How do I add a field to a specific step?
});
}
}How to reproduce
class TestFlow extends AbstractFlowType
{
public function buildFormFlow(FormFlowBuilderInterface $builder, array $options): void
{
$builder
->addStep('step1', Step1Type::class, [
'inherit_data' => true,
]);
}
}class Step1Type extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, static function (FormEvent $event) {
// This will not be called
});
}
}Possible Solution
No response
Additional Context
No response