“This value is not valid”

Home Forums Quform WordPress “This value is not valid”

This topic is: resolved
  • This topic has 2 replies, 2 voices, and was last updated 1 year ago by Ally.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #35265
    amplastic
    Participant

    Ive added the code below to my functions.php file so that it can pull product titles/sku’s and give those as an option in a field within my quform. However, when I choose an option and submit the form, it says “This value is not valid.” I made sure the setting on the field “Customize values” was enabled. How do i fix this?

    /* pull product data for claims form */
    add_action(‘quform_pre_display_1’, function (Quform_Form $form) {
    if (!is_admin()) { // Make sure we’re not in the admin area
    $element = $form->getElement(‘quform_1_17’);

    if ($element instanceof Quform_Element_Multi) {
    $options = array();
    $args = array(
    ‘posts_per_page’ => -1,
    ‘post_type’ => ‘product’,
    ‘tax_query’ => array(
    array(
    ‘taxonomy’ => ‘product_visibility’,
    ‘field’ => ‘name’,
    ‘terms’ => ‘exclude-from-catalog’,
    ‘operator’ => ‘NOT IN’,
    ),
    ),
    );

    $query = new WP_Query($args);

    if ($query->have_posts()) {
    while ($query->have_posts()) {
    $query->the_post();
    $title = html_entity_decode(get_the_title()); // Decode HTML entities in the title

    if (strpos($title, ‘Body Kit’) === false &&
    strpos($title, ‘Mufflers’) === false &&
    strpos($title, ‘Sticker’) === false
    ) { // Exclude products with specified strings in the title
    $product = wc_get_product(get_the_ID());
    if ($product) {
    $sku = $product->get_sku() ? ‘ (‘ . $product->get_sku() . ‘)’ : ”;
    $options[] = array(‘label’ => $title . $sku, ‘value’ => $title . $sku, ‘id’ => get_the_ID());
    }
    }
    }
    wp_reset_postdata();
    }

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

    • This topic was modified 1 year ago by amplastic.
    #35267
    amplastic
    Participant

    nvm i fixed it by disabling “Validate submitted value”

    #35271
    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 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy