Home › Forums › Quform WordPress › “This value is not valid”
- This topic has 2 replies, 2 voices, and was last updated 1 year, 7 months ago by Ally.
- AuthorPosts
- March 22, 2023 at 11:39 pm #35265amplasticParticipant
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 titleif (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, 7 months ago by amplastic.
March 23, 2023 at 12:16 am #35267amplasticParticipantnvm i fixed it by disabling “Validate submitted value”
March 23, 2023 at 8:20 am #35271AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.