Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

mpiot
Copy link
Contributor

@mpiot mpiot commented Feb 7, 2024

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #53823
License MIT

In the DomCrawler, the way to get fields via xPath avoid to find elements inside a <template> element:

<form>
    <template>
        <input type="text" name="not_selected_because_in_template" />
    </template>

    <input type="text" name="selected_because_out_of_template" />
</form>

But, it appear it also exclude form elements if the <form> is in a <template> (eg: in a <turbo-stream>), that bug-fix keep the previous behavior but allow the following:

<turbo-stream>
    <template>
        <form>
            <input type="text" name="selected_because_in_turbo_stream_1" />
            <input type="text" name="selected_because_in_turbo_stream_2" />
        </form>
    </template>
</turbo-stream>

As mentioned in #53823, an alternative should be to use [not(ancestor::template/ancestor::form)] in the xPath to allow:

<template>
    <form>
        <input type="text" name="selected_because_parent_is_form_1" />
        <input type="text" name="selected_because_parent_is_form_2" />
    </form>
</template>

@carsonbot carsonbot added this to the 6.4 milestone Feb 7, 2024
@carsonbot carsonbot changed the title [DomCrawler] [Form] Fix the exclusion of <template> [DomCrawler][Form] Fix the exclusion of <template> Feb 7, 2024
@nicolas-grekas
Copy link
Member

Thank you @mpiot.

@nicolas-grekas nicolas-grekas merged commit cff8011 into symfony:6.4 Feb 9, 2024
This was referenced Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants