• Resolved pare81

    (@pare81)


    Hi Greg,

    within the custom fields plugin, there is no option to make category and image required. I like to have both fields required, do you have an info for this?

    Thanks
    and regards
    Pare

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    the category field you can make required by unchecking the empty option, the Gallery does not have any options i am afraid as it behaves a bit differently than other fields.

    Thread Starter pare81

    (@pare81)

    Hi,

    thanks,

    but if I uncheck the empty option and have choosed only 1 Option is accept, the first Option of the list is prefilled. So Its filled out automatically and I like to have, that the user havt to choose the right category and not automatically the first, if the user not change this value.

    and if empty option is checked, the listing is saved without category, if the user nothing selects.

    Best regards,
    pare

    • This reply was modified 7 years, 11 months ago by pare81.
    Plugin Author Greg Winiarski

    (@gwin)

    Ok, the required option will be added to the Custom Fields editor in next release, in the meantime you will need to add following code to your theme functions.php

    
    add_filter("adverts_form_load", "make_category_required");
    function make_category_required( $form ) {
        if($form["name"] != 'advert' || is_admin()) {
            return $form;
        }
        $count = count( $form["field"] );
    
        for( $i = 0; $i < $count; $i++ ) {
            if($form["field"][$i]["name"] == "advert_category") {
                $form["field"][$i]["validator"] = array(
                    array( "name" => "is_required" )
                );
            }
        }
    
        return $form;
    }
    
    Thread Starter pare81

    (@pare81)

    Thanks a lot!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Category and image required option’ is closed to new replies.