Skip to content
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

Data option not working #26

Closed
bouvetb opened this issue Jun 5, 2024 · 5 comments
Closed

Data option not working #26

bouvetb opened this issue Jun 5, 2024 · 5 comments

Comments

@bouvetb
Copy link

bouvetb commented Jun 5, 2024

Hello,
I'm trying to use the bundle to display selects only if previous value has been selected and select a default value in the list but when i use the 'data' parameters in my dependent form type no options is selected by default. I'm working with live components.
Here is my dependent field declaration :
image
If i'm in edit mode the data are populated well.
My form is configurated with no data_class

@Huluti
Copy link

Huluti commented Jun 26, 2024

Same for me. With this code, the domain field doesn't change its value when an other folder is selected:

$builder->addDependent('domain', 'folder', function (DependentField $field, ?Folder $folder) {
            $field->add(EntityType::class, [
                'class' => Domain::class,
                'choice_label' => 'host',
                'choice_value' => fn (?Domain $entity): string => $entity ? $entity->getPublicId()->toRfc4122() : '',
                'choices' => $folder?->getTeam()->getDomains(),
                'label' => 'links.form.domain_label',
                'help' => 'links.form.domain_help',
                'required' => false,
                'data' => $folder?->getDomain(),
            ]);
        });

@momocode-de
Copy link

I have the same problem. Even if I pass the initial value to the domain data object, the value is removed as soon as my field becomes visible. Does anyone already have a solution or workaround?

@momocode-de
Copy link

I did some debugging and found out that it could be solved by an adjustment in the ComponentWithFormTrait of the UX Bundle. I created a new issue for this in the UX Bundle: symfony/ux#2369

@sadikoff
Copy link

So can we consider that this issue is not related to dynamic-form and close it?

@bouvetb
Copy link
Author

bouvetb commented Nov 18, 2024

ok i close it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants