Home › Forums › Quform WordPress › Populate dropdown
- This topic has 12 replies, 2 voices, and was last updated 4 years, 8 months ago by Icemanmx.
- AuthorPosts
- July 10, 2019 at 4:24 am #29608IcemanmxParticipant
Hello
I want to populate dropdown from standalone database, i have this code:
<?php/*
* Plugin Name: Population of code
* Description: Special code quform2.
* Version: 2.0
*/// Start Encuesta Post Evento with codes.txt file.
//quform_error_log($result);
function mytheme_dynamic_dropdown_values($form)
{
$db = new wpdb('xxx', 'xxx', 'xxx', 'localhost');
$results = $db->get_results("SELECT * FROM code", ARRAY_A);$options = array();
foreach($results as $row) {
$options[] = array('label' => $row['CODE'], 'value' => $row['CODE']);
}$dropdown = $form->getElement('quform_3_3');
if ($dropdown instanceof quform_Element_Select) {
$dropdown->setOptions($options);
}
}
add_action('quform_pre_display_3', 'mytheme_dynamic_dropdown_values');?>
But it dows not show me nothing, i also changed fron iphorm to quform
Any help how to do this in Quform2?Best Regards
IcemanmxJuly 11, 2019 at 9:13 pm #29623IcemanmxParticipantAnyone can help?
July 12, 2019 at 10:42 am #29629AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
July 12, 2019 at 4:27 pm #29631IcemanmxParticipantHello
I put all in one zip file, screens and debug logs, server log and wp debug log.
I need to say i have php 7.3 installed…Best Regards
IcemanmxAttachments:
You must be logged in to view attached files.July 17, 2019 at 3:59 am #29652IcemanmxParticipantHello
Someone took a look yet?Icemanmx
July 19, 2019 at 10:50 am #29657AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
July 21, 2019 at 6:29 pm #29665IcemanmxParticipantThanks, that worked, and you right i did not type right the column name.
1000 thanks
Best Regards
IcemanmxAttachments:
You must be logged in to view attached files.July 22, 2019 at 12:25 am #29667IcemanmxParticipantOk
One more thing i forgot about..
Now when i have the code in the database, how can i read it from database and validate that the code excist before sending the form data.function encuesta_notification_content( PHPMailer $mailer, Quform_Notification $notification, Quform_Form $form ) { ob_start(); include __DIR__ . '/encuesta-post-evento.php'; $mailer->Body = ob_get_clean(); } add_filter( 'quform_pre_send_notification_1_1', 'encuesta_notification_content', 10, 3 ); add_filter( 'quform_element_valid_1_37', function ( $valid, $value, $element ) { //$pathcheck = WP_PLUGIN_DIR . '/surveyhdapg/codes.txt'; // This just checking the path to the wp-plugin folder. //echo '<script language="javascript">'; //echo 'alert("Path:' . $pathcheck . '")'; //echo '</script>'; $codes = file( WP_PLUGIN_DIR . '/surveyhdapg/codes.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ); if ( !in_array( $value, $codes ) ) { $element->addError( 'Código no válido' ); $valid = false; } return $valid; }, 10, 3 );
I hope i explained it okay…
Best Regards
Icemanmx- This reply was modified 4 years, 8 months ago by Icemanmx.
July 23, 2019 at 11:44 am #29674AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
July 23, 2019 at 7:06 pm #29677IcemanmxParticipantHello
I get onlyThis value is not valid
.
I have zipped one file with the codes and the sql so maybe you can help me with it, i really need this…I really don´t want to disturb you so much, but i can´t find the problem by my self…
Best Regards
Icemanmx- This reply was modified 4 years, 8 months ago by Icemanmx.
Attachments:
You must be logged in to view attached files.July 29, 2019 at 10:35 pm #29692IcemanmxParticipantPlease, anyone can help me to get it right?
Best Regards
IcemanmxJuly 30, 2019 at 10:09 am #29699AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
July 30, 2019 at 4:28 pm #29705IcemanmxParticipantThanks Ally
This function perfect, 1000 thanks again for your support.Best Regards
Icemanmx - AuthorPosts
- You must be logged in to reply to this topic.