Quform v2 Set Default Value Dynamically for a Multiselect, Checkboxes

Home Forums Quform WordPress Quform v2 Set Default Value Dynamically for a Multiselect, Checkboxes

This topic is: resolved

This topic contains 4 replies, has 2 voices, and was last updated by  TerrenceLP 3 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #24582

    TerrenceLP
    Participant

    Hello,

    I’m trying to set a Default Value Dynamically but can’t figure how – below code was taken from a forum example.

    What will be a Quform 2 version?


    $atags = $form->getElement('quform_3_7');
    if ($atags instanceof iPhorm_Element_Select) {
    $atags->setDefaultValue('My Default Value');
    }

    What I’m trying to do is set a ‘Checked’ default value during the quform_pre_display, and there can be multiple Defaults as this is a pre-populated form that an editor will be reviewing and making updates to the article.

    #24639

    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.

    #24679

    TerrenceLP
    Participant

    I tried and my check boxes are still not checked when the form loads. I’ve attached my code.

    On Line 16 I build the multi checkboxes, this is where I’m not sure if this is over riding my setValues later in the code in the IF statement(line 252)

    This code is at line 252 in an IF statement(line 157) $aid = is this an edit or new?

    
                $stype = $form->getElement('quform_3_7');
                if ($stype) {
                    $stype->setValue($aid_results_types[0]['type_id']);
                }
                $stag = $form->getElement('quform_3_8');
                if ($stag) {
                    $stag->setValue($aid_results_tags[0]['tag_id']);
                }
    

    I have the values but still not clear how to set multiple check boxes to checked in my pre-form-hook

    No worries on the delay, thanks for your help.

    • This reply was modified 3 months ago by  TerrenceLP. Reason: new file now a zip file
    #24701

    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.

    #24729

    TerrenceLP
    Participant

    Worked like a charm! And I did see it in the class but wasn’t sure how to call out. I’m a huge fan of version 2 so whatever it takes – Onward!

    Thanks again!

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

You must be logged in to reply to this topic.