tyxla / Gravity-Forms-Multiple-Form-Instances

Allows multiple instances of the same form to be run on a single page when using AJAX.
GNU General Public License v2.0
37 stars 23 forks source link

Fix input choice id replacement #44

Open ajoah opened 2 years ago

ajoah commented 2 years ago

Hi,

The commit https://github.com/tyxla/Gravity-Forms-Multiple-Form-Instances/commit/54628395afea01f252a4f3d3197914cb5f361287 breaks connection between label and input for choice fields.

Result :

<li class="gchoice gchoice_4_9_1">
    <input name="input_9" type="radio" value="par email" id="choice_1991267731_9_1">
    <label for="choice_1991267731_4_9_1" id="label_1991267731_4_9_1">par email</label>
</li>

id and for are not equal.

This PR fixes the issue.

However, i don't understant why the replacement is twice in the code :

            "for='choice_"                                                  => "for='choice_" . $random_id . '_',
            "id='label_"                                                    => "id='label_" . $random_id . '_',
            "id='choice_"                                                    => "id='choice_" . $random_id . '_',
            "for='input_" . $form['id'] . '_'                               => "for='input_" . $random_id . '_',
            "id='input_" . $form['id'] . '_'                                => "id='input_" . $random_id . '_',
            "id='choice_" . $form['id'] . '_'                               => "id='choice_" . $random_id . '_',

Only one group of these lines is necessary, no ?