KriesiMedia / enfold-library

Enfold WordPress Theme Code Snippet Library
84 stars 68 forks source link

No Html5 validation for Product Category Select option #17

Closed khm-developer closed 4 years ago

khm-developer commented 4 years ago

Hi,

Currently, No Html5 validation for Product Category Select option. that why every time we received error message like this. "Error! Please select a category.".....

How to solve this

InoPlugs commented 4 years ago

@khm-developer

Could you specify where and how to reproduce it ?

khm-developer commented 4 years ago

Below are the code for the new product creation page. This category list contains a search cat option and also cat dropdown option and default it is having mandatory. But that mandatory is not a html validation.

<?php if ( dokan_get_option( 'product_category_style', 'dokan_selling', 'single' ) == 'single' ): ?>

__( '- Select a category -', 'dokan-lite' ), 'hierarchical' => 1, 'hide_empty' => 0, 'name' => 'product_cat', 'id' => 'product_cat', 'taxonomy' => 'product_cat', 'title_li' => '', 'class' => 'product_cat dokan-form-control dokan-select2', 'exclude' => '', 'selected' => $selected_cat, ); wp_dropdown_categories( apply_filters( 'dokan_product_cat_dropdown_args', $category_args ) ); ?>
                            <?php elseif ( dokan_get_option( 'product_category_style', 'dokan_selling', 'single' ) == 'multiple' ): ?>
                                <div class="dokan-form-group">
                                    <?php
                                    include_once DOKAN_LIB_DIR.'/class.taxonomy-walker.php';
                                    $selected_cat  = dokan_posted_input( 'product_cat', true );
                                    $selected_cat  = empty( $selected_cat ) ? array() : $selected_cat;
                                    $drop_down_category = wp_dropdown_categories( apply_filters( 'dokan_product_cat_dropdown_args', array(
                                        'show_option_none' => __( '', 'dokan-lite' ),
                                        'hierarchical'     => 1,
                                        'hide_empty'       => 0,
                                        'name'             => 'product_cat[]',
                                        'id'               => 'product_cat',
                                        'taxonomy'         => 'product_cat',
                                        'title_li'         => '',
                                        'class'            => 'product_cat dokan-form-control dokan-select2',
                                        'exclude'          => '',
                                        'selected'         => $selected_cat,
                                        'echo'             => 0,
                                        'walker'           => new DokanTaxonomyWalker()
                                    ) ) );
                                    echo str_replace( '<select', '<select data-placeholder="'.__( 'Select product category', 'dokan-lite' ).'" multiple="multiple" ', $drop_down_category );
                                    ?>
                                </div>
                            <?php endif; ?>