Labels mismatch, dynamic server side validation and quform

Home Forums Quform WordPress Labels mismatch, dynamic server side validation and quform

This topic is: not resolved

This topic contains 1 reply, has 2 voices, and was last updated by  Ally 3 months, 1 week ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #24267

    Hiyou
    Participant

    Hi, I’m using the following code for populating checkboxes server side:


    add_action('quform_pre_display_1', function (Quform_Form $form) {
    $select = $form->getElement('quform_1_3');

    if ($select) {
    $options = array();
    $posts = get_posts(array('numberposts' => -1, 'post_type' => 'travel'));

    foreach ($posts as $post) {
    $options[] = array('label' => $post->post_title, 'value' => $post->post_title);
    }

    $select->setOptions($options);
    }
    });

    These generate the following code:


    <div class="quform-options quform-cf quform-options-block">
    <div class="quform-option"><input type="checkbox" name="quform_2_4[]" id="quform_2_4_097128_0" class="quform-field quform-field-checkbox quform-field-2_4 quform-field-2_4_0" value="119"><label for="quform_2_4_097128_0" class="quform-option-label quform-option-label-2_4_0"><span class="quform-option-text">Title 1</span></label></div>
    <div class="quform-option"><input type="checkbox" name="quform_2_4[]" id="quform_2_4_097128_0" class="quform-field quform-field-checkbox quform-field-2_4 quform-field-2_4_0" value="120"><label for="quform_2_4_097128_0" class="quform-option-label quform-option-label-2_4_0"><span class="quform-option-text">Title 2</span></label></div>
    <div class="quform-option"><input type="checkbox" name="quform_2_4[]" id="quform_2_4_097128_0" class="quform-field quform-field-checkbox quform-field-2_4 quform-field-2_4_0" value="121"><label for="quform_2_4_097128_0" class="quform-option-label quform-option-label-2_4_0"><span class="quform-option-text">Title 3</span></label></div>
    <div class="quform-option"><input type="checkbox" name="quform_2_4[]" id="quform_2_4_097128_0" class="quform-field quform-field-checkbox quform-field-2_4 quform-field-2_4_0" value="122"><label for="quform_2_4_097128_0" class="quform-option-label quform-option-label-2_4_0"><span class="quform-option-text">Title 4</span></label></div>
    </div>

    I got 3 issues/questions here:

    1. Bug: When the checkboxes are generated, the labels for all the checkboxes are incorrectly pointing to the first checkbox, I realized all the Ids for the checkboxes are all the same – how do I fix this?
    2. I have to switch off client-side validation of values – if I need to do client-side validation, how do I do it via the hook even if I dynamically pre-populate the values?
    3. I can’t find complete documentation on what how the attributes of Quform_Form $form object passed in the filters are used. The online documentation seems very scarce in this area, is there any documentation you can share so it’s easy for me to use the available filters / hooks?

    Thank you!

    #24319

    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.