Home › Forums › Quform WordPress › Quform v2 Set Default Value Dynamically for a Multiselect, Checkboxes
- This topic has 4 replies, 2 voices, and was last updated 6 years ago by TerrenceLP.
- AuthorPosts
- March 6, 2018 at 5:09 pm #24582TerrenceLPParticipant
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.
March 13, 2018 at 10:58 am #24639AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 14, 2018 at 11:40 pm #24679TerrenceLPParticipantI 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 6 years ago by TerrenceLP. Reason: new file now a zip file
March 15, 2018 at 3:38 pm #24701AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 16, 2018 at 4:54 pm #24729TerrenceLPParticipantWorked 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!
- AuthorPosts
- You must be logged in to reply to this topic.