HomePhorge

AphrontFormPolicyControl: Reuse existing control ID

Description

AphrontFormPolicyControl: Reuse existing control ID

Summary:
Do not unconditionally create a new ID which breaks the accessibility label.

Parent AphrontFormControl::render() set an ID via $this->setID(celerity_generate_unique_node_id()) and then calls $this->renderInput() on its subclass AphrontFormPolicyControl which unconditionally runs $control_id = celerity_generate_unique_node_id() to assign another ID and then does 'id' => $control_id.
This breaks accessibility (AphrontFormControl's label for="UQ0_xx" is now off by one from AphrontFormPolicyControl's a id="UQ0_xx").

Similar existing code can be found in AphrontFormTokenizerControl::renderInput() at https://we.phorge.it/source/phorge/browse/master/src/view/form/control/AphrontFormTokenizerControl.php;bccd4f5981a7e2c347e8e26cf24d8394c882724f$57-61

Closes T16019

Test Plan: Create a Maniphest Task form which exposes policy controls. Check the resulting HTML if <label for=""> and <a id=""> match.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T16019

Differential Revision: https://we.phorge.it/D25910

Details