Variable "remote_url" does not exist

I have a nested form

demand
    home
       children
           n product

DemandType

class DemandTypeExtension extends AbstractTypeExtension {
    public function buildForm(...): void
    {
        $builder
            ->add('home', HomeType::class, [
            ]);

HomeType

class HomeType extends AbstractType {
    public function buildForm(): void {
        $builder
            ->add('children', CollectionType::class, [
                'entry_type' => ChildrenType::class,
                'allow_add' => true,
                'by_reference' => false,
                'allow_delete' => true,
                'prototype' => true,
                'label' => false,
            ]);
    }

    public function configureOptions(OptionsResolver $resolver): void {
        $resolver->setDefaults([
            'data_class' => Home::class,
        ]);
    }
}

ChildrenType

class ChildrenType extends AbstractType {
    public function buildForm(...): void
    {
        $builder
            ->add('name', TextType::class, [
        ])
        ->add('products', ProductAutocompleteChoiceType::class, [
            'multiple' => true,
            'by_reference' => false,
            'required' => false,
        ]);
    }

    public function configureOptions(OptionsResolver $resolver): void {
        $resolver->setDefaults([
            'data_class' => Children::class,
        ]);
    }

My form

{{ form_widget(form.home.children) }}

Variable “remote_url” does not exist.

It seems the remote_url is not set for block sylius_resource_autocomplete_choice_row.
I didn’t understand where remote_url is defined.

You have to pass the remote_url variable to the sylius_resource_autocomplete_choice_row
https://github.com/Sylius/Sylius/blob/2fe7bb24b40bd4d0e6c4650b442d6b5097e221d1/src/Sylius/Bundle/UiBundle/Resources/views/Form/theme.html.twig#L196-L215.
To do that , you have to use form_row instead of form_widget.
You can also define a form theme block for your form type, like Sylius does for Product and Taxon:
https://github.com/Sylius/Sylius/blob/2fe7bb24b40bd4d0e6c4650b442d6b5097e221d1/src/Sylius/Bundle/AdminBundle/Resources/views/Form/theme.html.twig#L22-L28

Thanks for your fast reply!

I have tried to define a block in my template, but I am unsure which block name I have to use.
The ChildrenType defines the block prefix children_type.

I have tried to define it like the following without success:

    {% block children_type_row %}
        {{ form_row(form, {'remote_url': path('sylius_admin_ajax_product_by_name_phrase'), 'load_edit_url': path('sylius_admin_ajax_product_by_code')}) }}
    {% endblock %}

    {% block children_type_products_row %}
        {{ form_row(form, {'remote_url': path('sylius_admin_ajax_product_by_name_phrase'), 'load_edit_url': path('sylius_admin_ajax_product_by_code')}) }}
    {% endblock %}

You can dump the form and look for unique_block_prefix in the vars array.
Then add _row to it, but also don’t forget to render it with form_row instead of form_widget.

Okay got it, but I am a little bit confused. I still get the error.
If I replace the form_row entry with a simple message it works.

I was expecting the block is only rendered if it is used in the template and not if is defined like in the theme.html.twig or is it a special file and handled different by twig?

You have to define those blocks only for the autocomplete fields, i.e. the products field inside ChildrenType.
The theme.html.twig is not a special file handled differently, unless it’s imported as a form theme.
You can read more about it at: https://symfony.com/doc/current/form/form_themes.html

Then I am wondering why I didn’t need it when I used it directly under the demand type.