-
-
Notifications
You must be signed in to change notification settings - Fork 373
Open
Description
Hello,
I'll try to be as clear as possible about my problem.
I'm using a form with Live Component and I have two dependent lists. In this case, I'm using "Dependent Form Fields" (https://ux.symfony.com/demos/live-component/dependent-form-fields). So far, everything's working.
$builder
->add('name', TextType::class, [
'label' => $options['prefix_label'].'fields.name',
])
->add('category', EntityType::class, [
'label' => $options['prefix_label'].'fields.category',
'placeholder' => $options['prefix_label'].'fields.category',
'class' => Category::class,
'required' => true,
'query_builder' => function (EntityRepository $repository) {
return $repository->createQueryBuilder('category')
->addOrderBy('category.name', 'asc');
},
'choice_attr' => function (Category $category): array {
return [
'state' => $category->getState(),
];
}
])
->addDependent('position', 'category', function (DependentField $field, ?Category $category) {
$field->add(SortType::class, [
'groupSort' => 'category',
'groupValue' => $category,
]);
})
;
Except that in my case, I'm using a React component that renders the lists, and everything works there too.
When I modify the value of my first list, symfony correctly returns the values for the second list and updates the "data-symfony--ux-react--react-props-value" attribute.
<div {{ react_component('Components/Select', {
id: id,
name: name,
fullName: full_name,
options: choices|arrayValues,
value: value,
isError: not valid,
multiple: multiple,
disabled: disabled,
required: (required
and placeholder is none
and not placeholder_in_choices
and not multiple
and (attr.size is not defined or attr.size <= 1)
),
placeholder: (placeholder is not none and placeholder != '')
? (translation_domain is same as(false)
? placeholder
: placeholder|trans({}, translation_domain))
: null,
translationDomain: choice_translation_domain
}) }}></div>
However, my React component doesn't see the update to this attribute, and therefore doesn't reload my list of options.
<div data-controller="symfony--ux-react--react" data-symfony--ux-react--react-component-value="Components/Select" data-symfony--ux-react--react-props-value="{"id":"range_position","name":"position","fullName":"range[position]","options":[{"data":0,"value":"0","label":"En premier","attr":{"state":1},"labelTranslationParameters":[]},{"data":1,"value":"1","label":"En dernier","attr":{"state":1},"labelTranslationParameters":[]}],"value":"0","isError":false,"multiple":false,"disabled":false,"required":false,"placeholder":"S\u00e9lectionnez une position","translationDomain":false}">...</div>
Could you tell me if I've missed anything?
If you need part of my code?
Thanks
Metadata
Metadata
Assignees
Labels
No labels