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

Selecting a radio button with value "0" is not possible if another element is pre-selected #623

Open
NicoHaase opened this issue Jan 26, 2024 · 1 comment

Comments

@NicoHaase
Copy link

In a form in my project, a form holds two radio buttons for the field transfer with values 0 and 1. When the button with value 1 is pre-selected, I cannot change that. $form['transfer']->setValue('0'); does nothing, as Symfony\Component\Panther\WebDriver\WebDriverCheckbox::getRelatedElements does not yield any field selector when $value = '0'

I could get this working when modifing the first line of that method from

$valueSelector = $value ? sprintf(' and @value = %s', XPathEscaper::escapeQuotes($value)) : '';

to

$valueSelector = !is_null($value) ? sprintf(' and @value = %s', XPathEscaper::escapeQuotes($value)) : '';
@WubbleWobble
Copy link

WubbleWobble commented Feb 1, 2024

Bizarre - I've just chased down this exact same issue, and here it is top of the list :)

All I have to add is that it doesn't matter about pre-selected values. On a completely fresh form this bug also prevents me from selecting a checkbox/radio with a non-truthy value.

I had a ChoiceType form with two radios - {"Yes": "1", "No": "0"} - and trying to submit the form via Panther with {"confirm": "0"} ended up with it selecting "Yes" :D

(A workaround for my issue was to change my form to use the "choice_value" option to alter the strings that were being outputted on the HTML side whilst not changing the data values that the form returned via getData())

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

2 participants