-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access underlying data in the callback #4
Comments
…is not compatible with Symfony\Component\Form\FormBuilderInterface::add
Hi! Which data do you need access to exactly? What I mean is, suppose you are editing a For (A), you can, I think, just grab the public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder = new DynamicFormBuilder($builder);
// ...
$data = $options['data'] ?? null;
$builder->addDependent('mainFood', ['meal'], function(DependentField $field, string $meal) use ($data) {
// ...
}); For (B), I'm not sure if that's possible or not... I think (?) by the time we have let ALL of the fields submit their data and update the underlying object, it is now too late for us to add new fields. I could be wrong - these form events are complicated, even for me (hence creating the library so we all don't need to think about them anymore). |
I want to access the global underlying object as it is. For example, in my custom dependent fields implementation, for some choice type I pass the "data" object, it allows me to populate the choice with some fields from the same global form and update it dynamically. For example on a form, I have a collection of "people" (name, surname) and I use this collection to populate another choice with theses names and it updates dynamically Thanks ! |
Does solution (A) work for you then? Or, if not, if you have a collection of "people" in your form and you use that to populate another choice, then wouldn't you use |
Hi,
I have a very complex form with multi interdependent fields and in some of them I need to get the main form's underlying data, is there a way to do this ?
The text was updated successfully, but these errors were encountered: