Quform v2 Dynamic default value pre display check boxes

Home Forums Quform WordPress Quform v2 Dynamic default value pre display check boxes

This topic is: resolved

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

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

    TerrenceLP
    Participant

    Hello,

    There is no Dynamic default value in QF2 documentation. Based on QF1 example –

    echo iphorm(1, array(
    ‘my_parameter’ => ‘Banana’,
    ‘my_parameter2’ => ‘Apple’
    ));

    What has to be done to set a Dynamic Default Values for a Checkbox Group? I have the function and the option values ready to do in my pre-display – but how do i pre-populate this element?

    #24416

    TerrenceLP
    Participant

    Taken from here – Original Post that helped me

    From the above post I was able to get what I needed. NOTE* I’m calling an external DB table.


    add_action('quform_pre_display_3', function (Quform_Form $form) {
    // Type form field ID = quform_3_7
    global $wpdb;
    $type_results = $wpdb->get_results( "SELECT id, name FROM master_media.type", OBJECT );
    $type_results = json_decode(json_encode($type_results), true);
    $type_results_array = array('0'=>'Default');
    $select_type = $form->getElement('quform_3_7');
    if ($select_type) {
    foreach ($type_results as $type_value) {
    $options_type[] = array('label' => $type_value['name'], 'value' => $type_value['id'], 'id' => $type_value['id']);
    }
    $select_type->setOptions($options_type);
    }
    });

    Works like a charm and always pulls the latest options from the DB.

    #24440

    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.

    #24942

    leredac
    Participant

    Bonjoiur

    when your add doc for dynamique value please ?
    Thank Terrence

    #24980

    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 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.